Attachment 'lecture4_buttonc.py'
Download
Toggle line numbers
1 #!/usr/bin/python
2 #Souce section 1
3
4 #mandatory for unix and linux
5 #---------------------------------------------------------------
6
7 from Tkinter import * #This library give us windows and buttons
8 from random import * #This library allows us to generate random numbers
9 #import library section 2
10
11 #
12 #What not to use???
13 #---------------------------------------------------------------
14
15 def one_to_ten():
16 ran = uniform(1,10)
17 print ran
18
19 def GoWork(): # def starts a function, or define a function
20 sum = 3*5
21 print sum #Function section 3
22
23 #----------------------------------------------------------------
24
25
26
27 #Code section 4
28
29 window = Tk() #i am the parent, button = child
30
31 stacy = Button(window, text = 'yoyo', command = one_to_ten)
32 #A rose with any other name would be just as sweet
33
34
35 stacy.pack() #you can name it after your fish (ignored)
36 window.mainloop() #youcan use your fish's name
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.