1 / 7

Tkinter

Tkinter. https://www.activestate.com/activetcl/downloads C:ActiveTclbin; ortam değişkenlerinde PATH ekliyoruz. C:Python34Script , ortam değişkenlerine ‘pip ‘ çalıştırmak için ekliyoruz. Hello World. from Tkinter import *

rferrer
Download Presentation

Tkinter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tkinter • https://www.activestate.com/activetcl/downloads • C:\ActiveTcl\bin; ortam değişkenlerinde PATH ekliyoruz. • C:\Python34\Script , ortam değişkenlerine ‘pip ‘ çalıştırmak için ekliyoruz.

  2. Hello World from Tkinter import * root = Tk(className ="My first GUI") #add a root window named Myfirst GUI foo = Label(root,text="Hello World") # add a label to root window foo.pack() root.mainloop()

  3. Komponents • foo = Label(root,text="SomeLabeltext here") # add a labeltorootwindow • foo = Message(root,text=" SomeLongtext here")# usedinstead of label, whenthetext is long • foo = Button(root,text="Login",command= function_when_pressed) # button - discussed in nextexample • foo = Entry(root,textvariable=svalue) # adds a textareawidget • foo = Checkbutton(root,text="Tick Me", variable=ticked_yes) # tickbutton • foo = Radiobutton(root,text="Option1",variable=opt1, value="option1") #radiobutton • foo = Scale(root, label="Volume Control",variable=volume, from =0, to=10, tickinterval=2, orient='vertical', command=on_slide) # slider

  4. Button Veri Girişi fromTkinterimport * root = Tk(className ="My first GUI") svalue = StringVar() # definesthewidgetstate as string w = Entry(root,textvariable=svalue) # adds a textareawidget w.pack() def act(): print "youentered" print '%s' % svalue.get() foo = Button(root,text="Press Me", command=act) foo.pack() root.mainloop()

  5. Örnek1 fromTkinterimport * def hello(): print "Hello World" # Main rootwindow root = Tk() # A buttonwith a callbackfunction Button(root, text="Press here", command=hello).pack() # .pack() method is necessarytomakethebuttonappear # Eventloop root.mainloop()

  6. Örnek2 from tkinter import Tk, Label, Button class MyFirstGUI: def __init__(self, master): self.master = master master.title("A simple GUI") self.label = Label(master, text="This is our first GUI!") self.label.pack() self.greet_button = Button(master, text="Greet", command=self.greet) self.greet_button.pack() self.close_button = Button(master, text="Close", command=master.quit) self.close_button.pack() def greet(self): print("Greetings!") root = Tk() my_gui = MyFirstGUI(root) root.mainloop()

More Related