def make_window(): global win_num win_num += 1 win = TestWindow(size=(260, 200), title="Text fields %d" % (win_num)) win.tf1 = TextField(position=(20, 20), width=200) #say("Field 1 Height =", win.tf1.height) ### win.tf2 = TextField(position=(20, win.tf1.bottom + 10), width=200, text="Spam\nGlorious Spam", multiline=True, lines=2) #say("Field 2 Height =", win.tf2.height) ### win.tf3 = TextField(position=(20, win.tf2.bottom + 10), width=200, font=fancy) show_but = Button("Show", position=(20, win.tf3.bottom + 20), action=(show_text, win)) sel_but = Button("Select", position=(show_but.right + 5, win.tf3.bottom + 20), action=(select_text, win)) new_but = Button("New", position=(sel_but.right + 5, win.tf3.bottom + 20), action=make_window) win.add(win.tf1) win.add(win.tf2) win.add(win.tf3) win.add(show_but) win.add(sel_but) win.add(new_but) win.height = show_but.bottom + 20 win.tf1.become_target() win.show() return win
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 test(): win = Window(title="Exceptions", size=(200, 100)) but1 = Button("ApplicationError", action=raise_application_error) but2 = Button("Exception", action=raise_exception) win.place_column([but1, but2], left=20, top=20) win.shrink_wrap(padding=(20, 20)) win.show() application().run()
def test(): starter = Button("Start", action=start_task) stopper = Button("Stop", action=stop_task) win = Window(title="Tasks") win.place_column([starter, stopper], left=20, top=20, spacing=20) win.shrink_wrap(padding=(20, 20)) win.show() application().run()
def make_window(self, document): self.tabview = view = TabView() win = Window(size=(600, 400), document=document) self.view1 = Button(title='Item 1', action=self.item1Action) view.add_item(self.view1, title='asdfe') self.view2 = Button(title='Item 2', action=self.item2Action) view.add_item(self.view2, title="Two") win.place(view, left=0, top=0, right=0, bottom=0, sticky='nsew') win.show()
def __init__(self, network, color): self.screen = None self.scale = START_SCALE self.base_x, self.base_y = None, None self.paused = False self.running = False self.clock = None self.network = network self.color_id = color self.colors = COLORS self.color = COLORS[self.color_id] self.c = 0 self.placing_cells_mode = True self.showing_info_mode = False self.eating_mode = False self.w, self.h = None, None self.alive = None self.new_round_info = Note(15, 15, WIDTH - 30, HEIGHT - 30) self.scores = None self.caption = "Life game" self.captions = { "eat": "Eating time", "place_cells": "Placing cells time", "show_info": "" } self.watching_settings = False self.color_picker = ColorPicker(20, 20, WIDTH - 40, HEIGHT - 40, job_on_set=self.set_color) close_btn_icon = "x.png" self.close_color_picker_btn = Button( WIDTH - 70, 30, job_on_click=self.close_color_picker, icon_path_1=close_btn_icon, icon_path_2=close_btn_icon) self.settings_button = Button(20, 20, job_on_click=self.open_settings, icon_path_1="settings44px.png", icon_path_2="settings44px.png")
def make_window(): global win_num win_num += 1 win = TestWindow(size = (320, 200), title = "Text fields %d" % (win_num)) win.tf1 = TestTextField(1, position = (20, 20), width = 200) win.tf2 = TestTextField(2, position = (20, win.tf1.bottom + 10), width = 200, text = "Spam\nGlorious Spam", multiline = True, lines = 2) win.tf3 = TestTextField(3, position = (20, win.tf2.bottom + 10), width = 200, font = fancy) win.tf4 = TestTextField(4, position = (20, win.tf3.bottom + 10), width = 200, editable = False, value = "Read Only") buty = win.tf4.bottom + 20 show_but = Button("Show", position = (20, buty), action = (show_text, win)) sel_but = Button("Select", position = (show_but.right + 5, buty), action = (select_text, win)) set_but = Button("Set", position = (sel_but.right + 5, buty), action = (set_text, win)) new_but = Button("New", position = (set_but.right + 5, buty), action = make_window) win.add(win.tf1) win.add(win.tf2) win.add(win.tf3) win.add(win.tf4) win.add(show_but) win.add(sel_but) win.add(set_but) win.add(new_but) win.width = new_but.right + 20 win.height = show_but.bottom + 20 win.tf1.become_target() win.show() return win
def make_window(): global win_num global tiedot nimi = "" win_num += 1 win = TestWindow(size=(320, 200), title="Text fields %d" % (win_num)) win.tf1 = TestTextField(1, position=(nimiLabel.right + 20, 20), width=200, text="") buty = win.tf1.bottom + 20 ## buttons = [RadioButton(x = engLabel.right + 20 * i, y = win.tf3.bottom + 20, title = "", group = grp) for i in range(1,6)] ## for i, v in enumerate(buttons): ## v.set_value(i+1) show_but = Button("Show", position=(20, buty), action=tiedot.append(repr(win.tf1.text))) win.add(nimiLabel) win.add(win.tf1) win.add(show_but) win.width = win.tf1.right + 20 win.height = show_but.bottom + 20 win.tf1.become_target() win.show() return win
def make_window(): win = Window(size=(240, 100), title="Password") tf = TextField(position=(20, 20), width=200, password=True) ok = Button("OK", position=(20, 60), action=(show, tf)) win.add(tf) win.add(ok) win.show()
def __init__(self, callback, panel_pos, name, label, x, y, w, h, activated_color=GREEN, deactivated_color=GREY): self.callback = callback self.panel_pos = panel_pos self.name = name self.activated_color = activated_color self.deactivated_color = deactivated_color self.gui_element = Button(self._do_action, (x + panel_pos[0], y + panel_pos[1]), (w, h), label, self.activated_color, anchor=TOPLEFT) self.down = False self.activated = True self.disabled = False self.handle_mouse_events = True
def __init__(self): self.screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32) #pygame.display.set_caption(u'中国象棋') #.encode('utf-8')) self.selected = None self.last_moved = None self.last_checked = False #self.done = None self.surface = load_image('board.png') self.select_surface = load_image_alpha('select.png') self.done_surface = load_image_alpha('done.png') self.over_surface = load_image_alpha('over.png') self.pieces_image = {} #self.back_btn = Button(self.back_btn_clicked, (WIDTH+100, 40), (180, 40), 'BACK') #, anchor=BOTTOMRIGHT) self.back_btn = Button(self.back_btn_clicked, (WIDTH + 100, 82), (180, 40), 'GoBack') #, anchor=BOTTOMRIGHT) self.next_btn = Button(self.next_btn_clicked, (WIDTH + 100, 124), (180, 40), 'NextGame') #, anchor=BOTTOMRIGHT) self.prev_btn = Button(self.prev_btn_clicked, (WIDTH + 100, 166), (180, 40), 'PrevGame') #, anchor=BOTTOMRIGHT) self.restart_btn = Button(self.restart_btn_clicked, (WIDTH + 100, 40), (180, 40), 'RestartGame') #, anchor=BOTTOMRIGHT) self.info_box = InLineTextBox((WIDTH + 10, 186), 220, RED, anchor=TOPLEFT, default_text='') self.good_box = InLineTextBox((WIDTH + 10, 206), 220, RED, anchor=TOPLEFT, default_text='') for name in ['r', 'n', 'c', 'k', 'a', 'b', 'p']: self.pieces_image[name] = load_image_alpha(name + '.png') #self.check_sound = load_sound('check.wav') #self.move_sound = load_sound('move.wav') #self.capture_sound = load_sound('capture.wav') self.clock = pygame.time.Clock() self.board = ChessBoard() self.engine = [None, None]
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 __init__(self, application, *args, **kwargs): super(LauncherSingletonWindow, self).__init__(title="Launcher", resizable=False, zoomable=False, *args, **kwargs) self._application = application self._game_controller = GameController() self.auto_position = False self.position = (200, 250) self.size = (140, 170) self.resizable = 0 self.zoomable = 0 self.add( Button(position=(10, 10), size=(120, 25), title="Play Quake", action=self._btn_default)) self.add( Button(position=(10, 40), size=(120, 25), title="Play Tutorial", action=self._btn_tutorial)) self.add( Button(position=(10, 70), size=(120, 25), title="README", action=self._btn_readme)) self.add( Button(position=(10, 100), size=(120, 25), title="Licence", action=self._btn_licence)) self.add( Button(position=(10, 140), size=(120, 25), title="Quit Launcher", action=self._close_cmd))
def make_row(align): return Row([ CheckBox("One"), Label("Two"), TextField(text="Three", size=(100, 50)), Button("Four"), ], expand=2, align=align)
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 all(self): display = pygame.display.set_mode((1920, 1080), pygame.RESIZABLE) pygame.display.set_caption("Automata") fuente = pygame.font.SysFont('Comic Sans MS', 15) # Cargar las images button = pygame.image.load( "C:\\Users\\marco\\OneDrive\\Documentos\\Automatas\\Proyecto1\\GUI\\Images\\button.png" ) # Escalar imagenes button = pygame.transform.scale(button, (140, 75)) # Asignacion de botones boton = ButtonP(button, button, 350, 20) # Texto para el boton prueba = fuente.render("Prueba", True, (0, 0, 0)) #Prueba ventana while True: display.fill((100, 195, 199)) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: if self.cursor.colliderect(boton.rect): screenTK3 = Tk() size = self.screen_sizeW() screenTK3.geometry( f"430x150+{int(size[0] / 2) - 230}+{int(size[1] / 2) - 100}" ) screenTK3.title("Backpacker") textC = StringVar(value="Ingrese el alfabeto") labelC = Label(screenTK3, textvariable=textC).place(x=150, y=10) texcT = StringVar(value="Ingrese la expresión regular") labelT = Label(screenTK3, textvariable=texcT).place(x=150, y=50) Cost_field = Entry( screenTK3, textvariable=self.alphabet.introSymbol, width=25).place(x=150, y=30) time_field = Entry(screenTK3, textvariable=self.er.symbols, width=25).place(x=150, y=70) Button(screenTK3, text="OK", command=lambda: self.er.erValidate()).place( x=150, y=100) screenTK3.mainloop() if event.type == QUIT: pygame.quit() sys.exit() self.cursor.update() boton.update(display, self.cursor, prueba) pygame.display.update()
def __init__(self, **kwds): Window.__init__(self, **kwds) view = TestScrollableView(container=self, size=(300, 300), extent=(1000, 1000), scrolling='hv', anchor='ltrb') button = Button("Embedded", action=self.click) off = (300, 300) view.scroll_offset = off button.position = off view.add(button) self.shrink_wrap()
def main(): mainWindow = tk.Tk() mainWindow.title("Main Window") newMsg = msgBox.MessageBox("Tit", "Mess") newButton = button.Button(mainWindow, buttonText="A button", callBack=newMsg.showAskOrCancel) newButton.addSimpleButton() mainWindow.mainloop()
def test(): def bing(): say("Bing!") #fld._win_dump_flags() win = Window(title = "Shrink Wrap", resizable = 0) but = Button("Bing!", action = bing) cbx = CheckBox("Spam") fld = TextField(width = 100) win.place(but, left = 20, top = 20) win.place(cbx, left = but + 20, top = 20) win.place(fld, left = 20, top = but + 20) win.shrink_wrap() win.show() application().run()
def create_buttons(self): return [ Button("Scroll Left", action = ('scroll', -16, 0)), Button("Scroll Right", action = ('scroll', 16, 0)), Button("Scroll Up", action = ('scroll', 0, -16)), Button("Scroll Down", action = ('scroll', 0, 16)), Button("Small Extent", action = ('extent', 100, 100)), Button("Medium Extent", action = ('extent', 500, 500)), Button("Large Extent", action = ('extent', 1000, 1000)), self.h_scrolling_ctrl, self.v_scrolling_ctrl, self.border_ctrl, ]
def initializeImages(self, parent): self.images = [] self.imageNames = [] skins = [ file for file in os.listdir(os.path.join("Data", "Pics", "Actors")) if file[len(file) - 4:].upper() == ".PNG" ] for skin in skins: self.images += [ Image(file=os.path.join("Data", "Pics", "Actors", skin)) ] self.imageNames += [skin] btn = Button(title="Back", action=self.backClicked, style='default') btn.position = ((self.width - btn.width) / 2, self.height - btn.height - 10) self.add(btn)
def playGame(self): endPhaseButton = Button([600, 200], 150, 50, " End Phase", self.calendar.advancePhase) self.buttons.append(endPhaseButton) endPhaseButton.draw(self.gameSurface) while self.calendar.day <= self.maxCycles * 3: for player in self.players: player.deck.drawSix() while self.calendar.phase == "DAY": self.drawCalendarInfo() self.eventCheck() while self.calendar.phase == "DUSK": self.drawCalendarInfo() self.eventCheck() while self.calendar.phase == "NIGHT": self.drawCalendarInfo() self.eventCheck() while self.calendar.phase == "EXCHANGE": self.drawCalendarInfo() self.eventCheck()
def gui(): display = pygame.display.set_mode((300, 200)) sb = SlideBar(print, (150, 100), (200, 30), 0, 160, 1, interval=4) def func_b(): sb.color = RED red = Button(func_b, (300, 200), (60, 40), 'RED', anchor=BOTTOMRIGHT) def func_sb(value): red.topright = 300, value sb.func = func_sb sb.set(0) run = True while run: mouse = pygame.mouse.get_pos() for event in pygame.event.get(): if event.type == pygame.QUIT: run = False if event.type == pygame.MOUSEBUTTONDOWN: if mouse in sb: sb.focus() if mouse in red: red.click() if event.type == pygame.MOUSEBUTTONUP: red.release() sb.unfocus() display.fill(WHITE) sb.render(display) red.render(display) pygame.display.flip()
def __init__(self): Window.__init__(self, size = (200, 200)) self.filt = CheckBox("%ss only" % self.file_type.name) #self.multi = CheckBox("Multiple Selection") buts = [] if 'request_old_file' in functions: buts.append(Button("Old File", action = self.do_old_file)) if 'request_old_files' in functions: buts.append(Button("Old Files", action = self.do_old_files)) if 'request_new_file' in functions: buts.append(Button("New File", action = self.do_new_file)) if 'request_old_directory' in functions: buts.append(Button("Old Directory", action = self.do_old_dir)) if 'request_old_directories' in functions: buts.append(Button("Old Directories", action = self.do_old_dirs)) if 'request_new_directory' in functions: buts.append(Button("New Directory", action = self.do_new_dir)) self.place_column([self.filt] + buts, left = 20, top = 20) self.shrink_wrap(padding = (20, 20))
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)) # Main loop while running:
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 View, Button, FileDialogs, Label, Font
from GUI import View, Button, Image
output=True) data = wf.readframes(CHUNK) while data != '': stream.write(data) data = wf.readframes(CHUNK) stream.stop_stream() stream.close() p.terminate() btn1 = Button(position=(30, 30), title="Start", action=start_recording, style='default') btn4 = Button(position=(30, 30), title="Stop", action=stop_recording, style='default') btn5 = Button(position=(230, 30), title="Play", action=play_recording, style='default') """btn2 = Button(x = 30, y = btn1.bottom + 30, width = 200, title = "Goodbye", just = 'centre', action = say_goodbye, enabled = 0) btn2.font = Font("Times", 1.2 * system_font.size, [])"""
def do_confirm_or_cancel(): say("Doing confirm_or_cancel") result = confirm_or_cancel( "Orpuddex is attacking.\nWhat is your response?", "Retaliate", "Surrender", "Run Away") say("Result =", result) win = Window(title="Alerts") rg = RadioGroup() rb = [] for kind in kinds: rb.append(RadioButton(kind.capitalize(), value=kind, group=rg)) rg.set_value('stop') pb = [ Button(title="Alert", action=do_alert), Button(title="Alert2", action=do_alert2), Button(title="Alert3", action=do_alert3), ] pb2 = [ Button("Note Alert", action=do_note_alert), Button("Stop Alert", action=do_stop_alert), Button("Ask", action=do_ask), Button("Confirm", action=do_confirm), Button("Ask or Cancel", action=do_ask_or_cancel), Button("Confirm or Cancel", action=do_confirm_or_cancel), ] win.place_column(pb, left=20, top=20) win.place_column(rb, left=pb[2] + 20, top=20) win.place_column(pb2, left=rb[1].right + 20, top=20) win.size = (pb2[-1].right + 20, pb2[-1].bottom + 20)