Mind map
Python : Graphical User interface (GUI)

Map content
Python : Graphical User interface (GUI)
To create a GUI Application we should first import the 'tkinter' module , and create a Object of the class'Tk' that object is our application
- Our Application contains some elements.To run the application and those element we use : App_name.mainloop()
- The Root Window : it's like the box wich contains all the other elements
- The widges : are some elements like : Buttons,Labels,Checkbox....
- Our Application contains some elements.To run the application and those element we use : App_name.mainloop()
Some widges and how to use them
- Button : we can create Buttons using the Button function that take as arguments: Button(App_name,text="the text to insert",command="function's name")
- To make the Button visible for te user we can use a lot of functions . the basic one is the pack() function :App_name.pack()
- Label :we can printor show a text in the Application using the Label() Function: Label(App_name,text='What we want to show')
- Entry: used to take an input from the user : Entry(App_name)
- Checkbox: we can create checkBox using the checkbutton() function that take as arguments : checkbutton(App_name,text="Some text")
- we can use a variable wich has the value IntVar() or StringVar() to Label 1 if the box is checked and 0 if not, or a string(Uou should define it) if the box is checked and another if not.Using that, you have to add 3 parameters to the function wich are: variable="variable's name",invalue='the value if the box is checked',offvalue='the value if not'
- Radio Buttons : are some Buttons that we can't check mor than one Button,like the checkbutton(),Radiobutton() has the same parameters except on and off value that are replaced by value
- Slider : used to select value that be minimum as"number_1" to maximum as"number_2",We write : Scale(App_name,from_="start number",to="End number",variable=variable's name=> this one is optional)
- DropDown Menu : we can create dropdown menu writing : OptionMenu(App_name,"variable's name=>optional, *the list that contains words that we pass as dropdown menu values ) . We can also define a defaul value from the given , to do that, we should use:variable's name.set('The defaul value')
- Button : we can create Buttons using the Button function that take as arguments: Button(App_name,text="the text to insert",command="function's name")
Using the grid system, font,backgrounds,foregrounds....
- As we mentioned previously,there is diffrent ways to show a widge, Now we will know the "Grid System"
- Using grid()Function,we can show and place a widge as we want in the positions that we want
- grid(row="row's number",column,=column'snumber,(columnspan="how much columns the element will take",padx='Horizontal padding',pady="vertical padding")=>optional)
- Using grid()Function,we can show and place a widge as we want in the positions that we want
- we can define the background and foreground colors of a widges : widge_Function(....,background="Color's name or the hex value",foreground="Color's name or the hex value")
- we can define a font for the label widge or any widge that contains a text,to do that we write: Widge_Funcion(....., font=("Fonct's name",the size))
- As we mentioned previously,there is diffrent ways to show a widge, Now we will know the "Grid System"
Working with Images in a GUI Application
- We can change the icon of our Application. To do that we need to use : App_name.iconbitmap(r"The location of the icon")
- Firs we should install the PIL module, that one alloxs us to work and use images in our GUI Application
- After installing the PIL Module we import it and create a variable with value: ImageTk.PhotoImage(Image.open(r'the location of the image')) and after that we creat a Label widge but this time with a parameter image instead of text
Use the dialog box in our GUI Application
- First we should import the filedialog Module from the tkinter Packege : From tkinter.filedialog import askopenfilename
- Then we write : App_name.filename=askopenfilemane(initialdir='the directry or the folder where we start ',title="the title of the dialog box",filetype=("File type","the element.extension"))
- First we should import the filedialog Module from the tkinter Packege : From tkinter.filedialog import askopenfilename
Images and files in the map
Information
- Description
- Mind Map on Python : Graphical User interface (GUI), created by Briache Issam on 03/09/2021.
- Created by
- Briache Issam
- Views
- 0
- Rating




