Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tkinter Python User Interface

Similar presentations


Presentation on theme: "Tkinter Python User Interface"— Presentation transcript:

1 Tkinter Python User Interface
Leaving JES - return to Python IDLE In Python IDLE, type from tkinter import * # import Tkinter package myWin = Tk() # create a window myWin.mainloop()

2 Widgets Label to display text or an image Button to execute a command
Text to display text Checkbutton to select from options Radiobutton to select one of options Entry to enter text input Menu pull-down or popup menu

3 Simple example Save as xxx.py in C:\100
from tkinter import * def procOk(): print(“OK button is clicked”) def procCancel(): print (“Cancel button is clicked”) win = Tk() label = Label(win, text=“Hi!”) butOk = Button(win, text=“Ok”, fg=“red”, command=procOk) butCancel = Button(win, text=“Cancel”, bg=“yellow”, command=procCancel) label.pack() # place the label in window butOk.pack() # place the button in window butCancel.pack() win.mainloop() Save as xxx.py in C:\100 From the ‘Run’ menu, select ‘Run module.’

4 Lab_0415 Take a look at tutorial in and add examples of the following widgets into your program Checkbutton to select from options Radiobutton to select one of options Entry to enter text input Menu pull-down or popup menu Do not use images (package is not available at your machine) Do NOT to the grader


Download ppt "Tkinter Python User Interface"

Similar presentations


Ads by Google