def test(): win = Window(title="Frame") frm = Frame() frm.place_column([Label("This is"), Label("A frame")], left=0, top=0) frm.shrink_wrap() win.place(frm, left=30, top=30) win.shrink_wrap(padding=(30, 30)) win.show()
def __init__(self, action, **kwargs): title = 'Password' self._action = action lbl_text = action.get_pass_desc() ModalDialog.__init__(self, title=title) label = Label(lbl_text) self.txt_passwd = TextField(multiline=False, password=True) self.ok_button = Button("Connect", action="ok", enabled=True, style='default') self.cancel_button = Button("Cancel", enabled=True, style='cancel', action='cancel') self.place(label, left=padding, top=padding) self.place(self.txt_passwd, left=padding, top=label + padding, right=label.right if label.right > 260 else 260) self.place(self.cancel_button, top=self.txt_passwd + padding, right=self.txt_passwd.right) self.place(self.ok_button, top=self.txt_passwd + padding, right=self.cancel_button - padding) self.shrink_wrap(padding=(padding, padding))
def __init__(self, span, spanView): Window.__init__(self, style='modal_dialog') self.title = "Edit utterance data" self.span = span self.spanView = spanView # controls utterance_label = Label("Utterance ID") speaker_label = Label("Speaker code") self.place(utterance_label, left=20, top=20) self.place(speaker_label, left=20, top=utterance_label + 20) # self.place(Button("Confirm", action = "ok", enabled = True), left =20, top = speaker_label+20) # self.place(Button("Cancel", action = "cancel", enabled = True), right =20, top = speaker_label+20) # self.shrink_wrap(padding=(20, 20))
def main(): f = None args = sys.argv[1:] if args: fontsize = int(args[0]) sf = StdFonts.system_font f = Font(sf.family, fontsize, sf.style) #showfont("Using font", f) win = Window(title="Heights") if f: kwds = {'font': f} else: kwds = {} controls = [ Label(text="Label", **kwds), TextField(text="Text", **kwds), CheckBox(title="Check", **kwds), RadioButton(title="Radio", **kwds), Slider(orient='h', width=50), #Button(title = "Button", **kwds), ] #for ctl in controls: # say("Height of %r is %s" % (ctl, ctl.height)) win.place_row(controls, left=10, top=10) win.shrink_wrap(padding=(10, 10)) win.show() run()
def __init__(self, text, timeout): ModalDialog.__init__(self) label = Label(text) self.ok_button = Button("OK", action="ok", enabled=False) self.place(label, left=20, top=20) self.place(self.ok_button, top=label + 20, right=label.right) self.shrink_wrap(padding=(20, 20)) self.timer = Task(self.enable_button, timeout)
def main(): global cb1, cb2, rg win = Window(title="Place Me By Your Side", width=720, height=500) view1 = TestDrawing(width=320, height=200) cb1 = CheckBox(title="Check Me!", action=checked_it) cb2 = CheckBox(title="Check Me Too!", action=checked_it) rbs = [] for i in range(1, 4): rb = RadioButton(title="Hoopy Option %d" % i, value=i) rbs.append(rb) rg = RadioGroup(rbs, action=option_chosen) pb = Button(title="Push Me!", action=pushed_it) view2 = TestScrollableDrawing(width=300, height=300) label = Label(text="Flavour:") entry = TextField(width=200) win.place(view1, left=10, top=10, border=1) win.place_row([cb1, cb2], left=10, top=(view1, 20), spacing=20) win.place_column(rbs, left=view1 + 20, top=10) win.place(pb, right=-20, bottom=-10, anchor='rb') win.place(view2, left=rbs[0] + 20, top=10, right=-20, bottom=pb - 10, scrolling='hv', anchor='ltrb', border=1) win.place(label, left=10, top=(cb1, 20)) win.place( entry, left=10, top=(label, 10), #border = 1 ) entry.become_target() win.show() import GUI GUI.run()
def make_row(align): return Row([ CheckBox("One"), Label("Two"), TextField(text="Three", size=(100, 50)), Button("Four"), ], expand=2, align=align)
def modal_dialog(): #global dlog ### dlog = ModalDialog(title="Spanish Inquisition", size=(200, 140)) dlog.place(Label(text="Surprise!!!"), left=20, top=20) field = TextField() dlog.place(field, left=20, top=60, right=-20) field.become_target() dlog.default_button = DefaultButton() dlog.cancel_button = CancelButton() dlog.place(dlog.default_button, right=-20, bottom=-20) dlog.place(dlog.cancel_button, left=20, bottom=-20) dlog.center() result = dlog.present() say("Result =", result) dlog.destroy()
def setupComponents(self, parent, deadChar): self.size = CHARACTERSLOTSIZE self.cImg = CharacterImage(position=(self.width / 4 - 39 / 4, 9)) self.cImg.setupComponents() self.add(self.cImg) self.setItemImage(deadChar[1]) self.deadChar = deadChar t = deadChar[0] if len(t) > 10: t = t[:8] + "..." l = Label(text=t) l.position = (self.width / 2 - l.width / 2, 0) self.add(l) btn = Button(title="Revive", action=self.imageClicked, style='default') btn.position = (self.width / 2 - btn.width / 2, 59) self.add(btn)
def __init__(self, kind, prompt, width=None, lines=None, button_labels=None, default=None, cancel=None): #if width is None: # width = self._default_width #if lines is None: # lines = self._default_lines ModalDialog.__init__(self, style='alert') self.label = Label(text=self._wrap(prompt), lines=lines) if self.label.width < self._minimum_width: self.label.width = self._minimum_width self._create_buttons(*button_labels) #self.default_button = self._find_button(default) #self.cancel_button = self._find_button(cancel) self._layout(kind)
hs = "Smeggy" lbl.text = "%s Flavour %s" % (hs, i) menus = [ Menu("Flavour", [ ("Hoopy/^H", 'hoopy_cmd'), ("Smeggy/^S", 'smeggy_cmd'), ("-"), (["Vanilla/^V", "Raspberry/^R", "Chocolate/^C"], 'flavour_cmd'), ]) ] win = MenuTestWindow(title="Menus", size=(240, 60)) win.menus = menus lbl = Label("Select a Flavour", position=(20, 20), width=200) win.add(lbl) win.show() instructions = """ In addition to the standard menus, there should be a menu "Flavours" containing two options and three flavours. The most recently selected option should be checked in the menu. Upon selecting a flavour, the currently selected option and the index of the selected flavour should be displayed in the window. All items in the Flavours menu should have shifted key equivalents. """ say(instructions) application().run()
from GUI import Dialog, Label, Button, application from GUI.StdButtons import DefaultButton, CancelButton from testing import say class TestDialog(Dialog): def ok(self): say("OK") def cancel(self): say("Cancel") dlog = TestDialog(width=250) lbl = Label(text="Eject the tomato?") ok_btn = DefaultButton() cancel_btn = CancelButton() dlog.place(lbl, left=20, top=20) dlog.place(ok_btn, left=20, top=lbl + 20) dlog.place(cancel_btn, right=-20, top=lbl + 20) dlog.height = ok_btn.bounds[3] + 20 dlog.show() instructions = """ There should be a non-modal dialog with two buttons in 'default' and 'cancel' styles. The window should be movable but not resizable. Messages should be printed when the buttons are pressed (although they should not dismiss the dialog). Return and Enter should activate the
def __init__(self, session, transport, **kwargs): title = 'Login' self._session = session self._transport = transport if 'title' in kwargs: title = kwargs['title'] ModalDialog.__init__(self, title=title) label = Label('Key File:') btn_rsa = RadioButton(title='RSA', value='RSA') btn_dss = RadioButton(title='DSS', value='DSS') self.key_file_group = key_file_group = RadioGroup( items=[btn_rsa, btn_dss]) key_file_group.value = 'RSA' self.txt_key_file = txt_key_file = TextField(multiline=False, password=False) btn_browse_file = Button('Browse', action='choose_key_file', enabled=True) lbl_login = Label('Login') self.txt_login = TextField(multiline=False, password=False) if 'username' in kwargs: self.txt_login.text = kwargs['username'] lbl_passwd = Label('Password') self.txt_passwd = TextField(multiline=False, password=True) self.ok_button = Button("Connect", action="ok", enabled=True, style='default') self.cancel_button = Button("Cancel", enabled=True, style='cancel', action='cancel') self.place(label, left=padding, top=padding) self.place(btn_rsa, left=label + padding, top=padding) self.place(btn_dss, left=btn_rsa + padding, top=padding) self.place(txt_key_file, left=padding, top=btn_rsa + padding, right=240) self.place(btn_browse_file, left=txt_key_file, top=txt_key_file.top) self.place(lbl_login, left=padding, top=txt_key_file + padding) self.place(self.txt_login, left=padding, top=lbl_login + padding, right=btn_browse_file.right) self.place(lbl_passwd, left=padding, top=self.txt_login + padding) self.place(self.txt_passwd, left=padding, top=lbl_passwd + padding, right=btn_browse_file.right) self.place(self.cancel_button, top=self.txt_passwd + padding, right=btn_browse_file.right) self.place(self.ok_button, top=self.txt_passwd + padding, right=self.cancel_button - padding) self.shrink_wrap(padding=(padding, padding))
from GUI import Window, CheckBox, Label, TextField, Grid, application from testing import say items = [ [Label("Name"), TextField(width=100)], [Label("Age"), TextField(width=50)], [Label("Language"), CheckBox("Python")], ] grid = Grid(items) win = Window(title="Grid") grid.position = (10, 10) win.add(grid) win.shrink_wrap() win.show() instructions = """ There should be six components laid out in a grid of three rows and two columns. Each component should be centre-left aligned within its cell. """ say(instructions) application().run()
from GriddedWindow import GriddedWindow w = GriddedWindow(size=(401, 301), style='modal_dialog', title='DemoGui') theme_list_button = ListButton(width=150, titles=['Standard', 'Dark']) theme_list_button = ListButton(width=150, titles=['Standard', 'Dark']) text_label_slider = Slider(orient='h', width=150) volume_text_field = TextField(text='70', width=150) fps_list_button = ListButton(width=150, titles=['29.97', '60.0']) sound_checkbox = CheckBox(title='Sound') save_button = Button('Save', width=80) cancel_button = Button('Cancel', width=80) w.set_inner_sep(10) w.set_col_seps([80]) w.set_row_seps([10, 10, 10, 10, 30]) w.place_item(Label('Theme:'), 0, 0) w.place_item(Label('TextLabel'), 1, 0) w.place_item(Label('Volume:'), 2, 0) w.place_item(Label('FPS:'), 3, 0) w.place_item(theme_list_button, 0, 1) w.place_item(text_label_slider, 1, 1) w.place_item(volume_text_field, 2, 1) w.place_item(fps_list_button, 3, 1) w.place_item(sound_checkbox, 4, 1) w.place_item(save_button, 5, 0) w.place_item(cancel_button, 5, 1) w.show() application().run()
from GUI import View, Button, FileDialogs, Label, Font
from testing import say class TestWindow(Window): def mouse_down(self, event): say("Mouse down in", self.title) def key_down(self, event): say("Key down in", self.title) self.other.show() win1 = TestWindow(title="Fullscreen", style='fullscreen') win1.show() lbl = Label("Fullscreen", x=300, y=20) win1.add(lbl) win2 = TestWindow(title="Not Fullscreen") win1.other = win2 win2.other = win1 win2.show() instructions = """ There should be two windows, one fullscreen and one not fullscreen. The fullscreen window should have no title bar or other decorations and should fill the whole screen. Pressing a key should bring one or the other to the front. On MacOSX, the menu bar should be hidden when the fullscreen window is frontmost. Menu command key equivalents should still work.
def make_label(text, **kwds): #say("Creating label", text) return Label(text = text, **kwds)
c = event.char if c == '\r': print "Default" elif c == '\x1b': print "Cancel" else: Window.key_down(self, event) class TestTextField(TextField): def __init__(self, number, *args, **kwds): TextField.__init__(self, *args, **kwds) self.number = number nimiLabel = Label("Nimi:") nimiLabel.position = (20, 20) grp = RadioGroup() def set_to_1(): grp.value = 4 def make_window(): global win_num global tiedot nimi = "" win_num += 1 win = TestWindow(size=(320, 200), title="Text fields %d" % (win_num))
if p_i_value: new_text = address_line.text + ' | ' + p_i_value address_line.change_text(new_text) elif p_i_value: new_text = ' '.join(address_line.text.split()[:-2]) address_line.change_text(new_text) # Pygame setup pygame.init() screen = pygame.display.set_mode((700, 597)) timer = pygame.time.Clock() # Entry field search_line = TextBox((0, 450, 700, 50), '', search, 40) # Adress line address_line = Label((0, 497, 700, 100), '', 40, True) # Clear button clear_button = Button((600, 0, 100, 50), 'Сброс', clear, 28) # Postal index button postal_index_button = Button((600, 55, 100, 50), 'Индекс', postal_index, 28) # Filling gui gui = GUI() gui.add_page('Main', [search_line, address_line, clear_button, postal_index_button]) gui.open_page('Main') # Create first map create_new_map() map_image = pygame.image.load('map.png') # Draw map screen.blit(map_image, (0, 0))
src_r = rect_sized((0, 250), (1000, 500)) dst_r = rect_sized((380, 20), (300, 150)) self.nurse.draw(c, src_r, dst_r) #draw the nurse sign src_r = m_on.bounds dst_r = rect_sized((800, 2), (390, 325)) self.monitor1.draw(c, src_r, dst_r) #draw the top monitor src_r = m_on.bounds dst_r = rect_sized((800, 350), (390, 325)) self.monitor2.draw(c, src_r, dst_r) #draw the bottom monitor win = Window(size=(1300, 700)) view = dashboard(size=win.size) win.add(view) view.become_target() win.show() room1 = Label(text="Current Room") room2 = Label(text="Other Room") n1 = Label(text="Nurse's Phone") n2 = Label(text="Partner's Phone") view.place(room1, left=1160, top=25) view.place(room2, left=1160, top=375) view.place(n1, left=485, top=190) view.place(n2, left=480, top=420) application().run()