পৃষ্ঠাসমূহ

Sunday, 2 December 2018

Image Viewer in C++ with Source Code

* C++ Tutorial Demo with Source Code :

 I will show that how to make image viewer using wxDev C++ IDE

How to make image viewer :-



You need one button , one OpenFileDialog, One WxEdit , WxStaticBitmap

Open Button Code Here:-------

wxString filePath;
int w, h, NewW,NewH;
wxImage img;
int PhotoMaxSize = 250;
if (WxOpenFileDialog1->ShowModal()==wxID_OK){
    WxEdit1->SetValue(WxOpenFileDialog1->GetPath());
    filePath = WxEdit1->GetValue();
    img = wxImage(filePath, wxBITMAP_TYPE_ANY);
    w = img.GetWidth();
    h = img.GetHeight();
    if (w>h){
        NewW = PhotoMaxSize;
        NewH = PhotoMaxSize * h/w;
    }
    else{
        NewH = PhotoMaxSize;
        NewW = PhotoMaxSize * w/h;
    }
    
    img = img.Scale(NewW, NewH);
    WxStaticBitmap1->SetBitmap(img);
    WxStaticBitmap1->Refresh();
       
}




FOR MORE HELP : Please Watch My YouTube Video
Link - https://youtu.be/Z9p8MbgmZDg

Simple Media Player in C++

* C++ Tutorial Demo with Source Code :

 I will show that how to read Media File using wxDev C++ IDE

How to load media file :-


You need two button , one OpenFileDialog, One MessageDialog, WxMediaCtrl

Open Button Code Here:-------
                       wxString path;
if (WxOpenFileDialog1->ShowModal()==wxID_OK){
    path = WxOpenFileDialog1->GetPath();
    WxMediaCtrl1->Load(path);
    if (not WxMediaCtrl1->Load(path)){
        int msg = wxMessageBox("Please select media file", "Error", wxOK, WxMessageDialog1);
        if (msg = wxOK){
            Close();
        }
    }
    else{
      WxMediaCtrl1->Play();  
    }
    }


Play Button Code Here:------

 WxMediaCtrl1->Play();

FOR MORE HELP : Please Watch My YouTube Video
Link - https://youtu.be/u8529ccyBvQ

Wednesday, 14 November 2018

Tkinter : Progress Bar Demo

Python Glade : Connection between label and button

Python Glade : Connection between button and label

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class Handler:
    def OnShowClick(self,button):
        x.builder.get_object("label1").show_all()
   
   
    def OnChangeClick(self,button):
        x.builder.get_object("label1").set_text("My name is khafi")
   
   
    def OnHideClick(self,button):
        x.builder.get_object("label1").hide_on_delete()
   
   
    def OnExitClick(self,button):
        x.builder.get_object("window1").destroy()
   


class Example:
    def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file("Khafi.glade")
        self.builder.connect_signals(Handler())
        window = self.builder.get_object("window1")
        window.show_all()
    def main(self):
        Gtk.main()
x = Example()
x.main()

Glade Python : Image Viewer

Python Glade : Image Viewer

Python Glade Image Viewer :

import os
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio, GdkPixbuf

class Handler:
     def OpenButtonClick(self,button):
             
     
         dialog = Gtk.FileChooserDialog("Choose a Image",
                                    None,
                                     Gtk.FileChooserAction.OPEN,
                                    (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                     Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
         dialog.set_default_size(600, 300)

         response = dialog.run()
         if response == Gtk.ResponseType.OK:
             pic = dialog.get_filename()
             pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(pic,400,400,True)
           
             x.builder.get_object("image1").set_from_pixbuf(pixbuf)
         
           
         elif response == Gtk.ResponseType.CANCEL:
             print("Cancel")

         dialog.destroy()
 


class Example:
    def __init__(self):
        self.builder=Gtk.Builder()
        self.builder.add_from_file("ImageViewer.glade")       
     
        self.builder.connect_signals(Handler())
     
        window=self.builder.get_object("window1")
        window.show_all()
    def main(self):
        Gtk.main()
       
x=Example()
x.main()

Glade Python : How To Show About Form

Glade Python : How to show about form

To show about form :

  def OnAboutClick(self,button):
        x.builder.get_object("aboutdialog1").show_all()
   

Exit Button Code

Python Glade Tutorial : 


def OnExitClick(self,button):
        x.builder.get_object("window1").destroy()
   

Glade Python : Exit button code