mirror of
https://github.com/sys-32Dev/CS1010.git
synced 2026-08-08 20:05:59 +00:00
8
lab11/lab11-2.py
Normal file
8
lab11/lab11-2.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import tkinter
|
||||
box = tkinter.Tk()
|
||||
# set the size of the window, background color and title
|
||||
box.geometry("300x300")
|
||||
box.configure(bg="orange")
|
||||
box.title("This is the title!")
|
||||
|
||||
box.mainloop()
|
||||
15
lab11/lab11-3.py
Normal file
15
lab11/lab11-3.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import tkinter
|
||||
import random
|
||||
box = tkinter.Tk()
|
||||
# set the size of the window, background color and title
|
||||
box.geometry("300x300")
|
||||
box.configure(bg="orange")
|
||||
box.title("This is the title!")
|
||||
# create a label
|
||||
label_1 = tkinter.Label(box, text="This is a label!")
|
||||
label_1.pack()
|
||||
# create another label, with a different background color, font and font size
|
||||
label_2 = tkinter.Label(box, text="This is another label!", bg="blue", fg="white", font=("Comic Sans MS", 16, "bold"))
|
||||
label_2.pack()
|
||||
|
||||
box.mainloop()
|
||||
28
lab11/lab11-4.py
Normal file
28
lab11/lab11-4.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import tkinter
|
||||
import random
|
||||
box = tkinter.Tk()
|
||||
# define a function that will be called when the button is pressed, change the text of label_1
|
||||
def press():
|
||||
label_1.configure(text="You pressed the button!")
|
||||
# define another function that will be called when the button is pressed, change the text of label_1 and display a random number in label_2
|
||||
def press2():
|
||||
label_1.configure(text="here is a random number: ")
|
||||
label_2.configure(text=random.randint(1, 100))
|
||||
# set the size of the window, background color and title
|
||||
box.geometry("300x300")
|
||||
box.configure(bg="orange")
|
||||
box.title("This is the title!")
|
||||
# create a label
|
||||
label_1 = tkinter.Label(box, text="This is a label!")
|
||||
label_1.pack()
|
||||
# create another label, with a different background color, font and font size
|
||||
label_2 = tkinter.Label(box, text="This is another label!", bg="blue", fg="white", font=("Comic Sans MS", 16, "bold"))
|
||||
label_2.pack()
|
||||
# create a button
|
||||
button_1 = tkinter.Button(box, text="This is a button!", command=press)
|
||||
button_1.pack()
|
||||
# create another button, with a different background color, font and font size
|
||||
button_2 = tkinter.Button(box, text="This is another button!", bg="blue", fg="white", font=("Comic Sans MS", 16, "bold"), command=press2)
|
||||
button_2.pack()
|
||||
|
||||
box.mainloop()
|
||||
BIN
lab11/ug1TqC4LeG.png
Normal file
BIN
lab11/ug1TqC4LeG.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
Reference in New Issue
Block a user