Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_events():
a = App()
p = PushButton(a)
events_test(p)
a.destroy()
def test_grid_layout():
a = App(layout="grid")
w = PushButton(a, grid=[1,2])
grid_layout_test(w, 1, 2, 1, 1, None)
ws = PushButton(a, grid=[1,2,3,4])
grid_layout_test(ws, 1, 2, 3, 4, None)
wa = PushButton(a, grid=[1,2], align="top")
grid_layout_test(wa, 1, 2, 1, 1, "top")
a.destroy()
def test_update_command_with_args():
a = App()
callback_event = Event()
def callback(value):
assert value == "foo"
callback_event.set()
b = PushButton(a)
b.update_command(callback, ["foo"])
b.tk.invoke()
assert callback_event.is_set()
a.destroy()
from guizero import App, TextBox, Text, Slider, PushButton, Picture, Combo, CheckBox, ButtonGroup, Box
app = App(title="different sizes", width = 700, height=700)
text = Text(app, "lets change some sizes", width=20, height=2)
text_box = TextBox(app, "some text", width=50)
slider = Slider(app, width=300, height=30)
button = PushButton(app, width=20, height=2)
pic = Picture(app, image="guizero.gif", width=400, height=50)
combo = Combo(app, ["martin", "laura", "rik"], width="fill", height="fill")
check = CheckBox(app, "tick me", width=20, height=3)
check.bg = "blue"
button_group = ButtonGroup(app, ["cheese", "onion", "crisps"], 1, width=20, height=9)
button_group.bg = "darkgrey"
box = Box(app, width=100, height=100)
box.border = True
box.bg = "red"
palette.set_pixel(0,8, "black")
palette.set_pixel(0,9, (66,220,240))
box = Box(app, width=30,height=30,grid=[2,10,2,1])
box.bg =col
text_current_col = Text(app, text="Selected Colour:", grid=[0,10,3,1])
text_rotation = Text(app, text="LED Rotation:", grid=[5,10,3,1])
combo_rotation = Combo(app, options=["0", "90", "180", "270"],grid=[8,10,2,1],command=sh_rotation)
button_clear = PushButton(app, command=clear_matrix,grid=[8,1], text = "Clear")
button_clear.bg = col
frame_status_text = Text(app, text="Frame " + str(current_frame_number).zfill(3) + " of " + str(len(frames)).zfill(3), grid=[0,11,3,1])
button_new_frame = PushButton(app, command=new_frame,grid=[3,11,2,1], text = "New",padx=28)
button_new_frame = PushButton(app, command=copy_frame,grid=[5,11,2,1], text = "Duplicate")
button_new_frame = PushButton(app, command=delete_frame,grid=[7,11,2,1], text = "Delete", padx=20)
prev_matrix = Waffle(app,height=8,width=8,dim=8,color="grey",grid=[0,13,3,3])
next_matrix = Waffle(app,height=8,width=8,dim=8,color="grey",grid=[7,13,3,3])
menubar = MenuBar(app,
toplevel=["File"],
options=[
[ ["Import file", import_python],
["Export as", export_as_python]
]
])
if os.path.isfile("/proc/device-tree/hat/product"):
file = open("/proc/device-tree/hat/product","r")
hat = file.readline()
modal_window = Window(app, title="modal window", visible=False)
Text(modal_window, "modal window")
def open_modal():
modal_window.show(True)
def close_modal():
modal_window.hide()
open_window_button = PushButton(app, text="Open window", command=window.show)
open_modal_button = PushButton(app, text="Open modal window", command=open_modal)
close_window_button = PushButton(window, text="Close", command=window.hide)
close_modal_button = PushButton(modal_window, text="Close", command=close_modal)
app.display()
from guizero import App, TextBox, PushButton, Text
def show():
output.value = textbox.value
app = App()
textbox = TextBox(app, multiline=True, height=10, width=50, scrollbar=True)
textbox.value = "hello\ngoodbye\nno way\nthis is a very long stream of text, very long indeed, the best long line of text, its super bigly and very long, I dont think it could possibly be any better particularly as it was created by someone who is super good at creating long lines of text."
button = PushButton(app, text="Print", command=show)
output = Text(app)
app.display()
from guizero import App, ButtonGroup, CheckBox, Combo, PushButton, Slider, Text, TextBox
a = App(title="colors")
text = Text(a, text="colors")
check = CheckBox(a, "check me")
combo = Combo(a, ["red", "blue"])
button = PushButton(a)
slider = Slider(a)
textbox = TextBox(a, text="or colours")
bgroup = ButtonGroup(a, ["cheese", "ham", "salad"], 1)
a.bg = (255,255,0)
text.text_color = "red"
text.text_size = 30
text.font = "verdana"
text.bg = "green"
check.bg = "#d41789"
combo.bg = "blue"
combo.text_color = "green"
combo.text_size = 24
button.bg = "black"
button.text_color = (255,0,255)
button.font = "arial"
tb.width = None
t.height = None
t.text_color = None
t.font = None
t.text_size = None
s.width = None
p.width = None
pb.width = None
p.height = None
pb.height = None
b.bg = None
a = App()
tb = TextBox(a)
s = Slider(a)
p = PushButton(a)
pb = PushButton(a, image="guizero.gif")
t = Text(a, "Widget settings")
b = Box(a, layout="grid")
change_button = PushButton(b, text="change", command=change, grid=[0,0], align="left")
reset_button = PushButton(b, text="reset", command=reset, grid=[1,0], align="right")
a.display()
from guizero import App, PushButton
def pressed():
print("button was pressed")
def message(msg):
print(msg)
app = App()
button = PushButton(app, command=pressed, text='Press me')
print(button.width)
print(button.height)
button_with_args = PushButton(app, command=message, text='Say hi', args=["hi"])
app.display()