def initUI(self): self.parent.title("Buttons") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=GROOVE, borderwidth=5) frame.pack(fill=BOTH, expand=1) self.pack(fill = BOTH, expand = 1) self.imageLabel = Label(frame, image = "") self.imageLabel.pack(fill=BOTH, expand=1) closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT) okButton = Button(self, text="OK") okButton.pack(side=RIGHT) options = [item for item in dir(cv2.cv) if item.startswith("CV_CAP_PROP")] option = OptionMenu(self, self.key, *options) self.key.set(options[0]) option.pack(side="left") spin = Spinbox(self, from_=0, to=1, increment=0.05) self.val = spin.get() spin.pack(side="left")
class RadioButtonList: # Widget class def __init__(self, frm, name, ch1, ch2, st, i): self.frame = Frame(frm.frame) self.frame.grid() self.ch1 = ch1 self.ch2 = ch2 self.i = i self.st = st v = IntVar() self.v = v self.shuu = name self.length = len(name) self.rb = {} r = 0 self.r = r for txt, val in name: self.rb[r] = Radiobutton(frm.frame, text=txt, padx=20, variable=v, value=val, command=self.onclick) self.rb[r].grid(row=i + r, column=0, sticky=W, pady=2) r = r + 1 self.r = r def onclick(self): if self.ch1 == 1: if self.v.get() == self.ch2: self.st.set_text("true") # v.add(self.st,self.i+self.r+1) else: self.st.set_text("false") # v.add(self.st,self.i+self.r+1) else: self.st.set_text("Your choice:" + self.shuu[self.v.get() - 1][0])
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() #Clear the ROI counter self.roiIdx = 0
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand = 1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) okButton = Button(self, text = "OK") okButton.place(x = self.width - 200, y = self.height - 100) quitButton = Button(self.parent, text = "QUIT") quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize((int(self.width*scale), int(self.height*scale))) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image = self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x = 10, y = 10) info_x = int(self.width*scale) + 20 label_text_area = Tkinter.Label(self, text = "Message received:") label_text_area.place(x = info_x, y = 10) self.text_area = Tkinter.Text(self, height = 10, width = 40) self.text_area.place(x = info_x, y = 30)
def _setup_button_toolbar(self): ''' The button toolbar runs as a horizontal area at the top of the GUI. It is a persistent GUI component ''' # Main toolbar self.toolbar = Frame(self.root) self.toolbar.grid(column=0, row=0, sticky=(W, E)) # Buttons on the toolbar self.run_button = Button(self.toolbar, text='Run', command=self.cmd_run) self.run_button.grid(column=0, row=0) self.step_button = Button(self.toolbar, text='Step', command=self.cmd_step) self.step_button.grid(column=1, row=0) self.next_button = Button(self.toolbar, text='Next', command=self.cmd_next) self.next_button.grid(column=2, row=0) self.return_button = Button(self.toolbar, text='Return', command=self.cmd_return) self.return_button.grid(column=3, row=0) self.toolbar.columnconfigure(0, weight=0) self.toolbar.rowconfigure(0, weight=0)
def __init__(self, parent): Frame.__init__(self, parent) self.hourstr = tk.StringVar(self, datetime.datetime.today().hour) self.hour = tk.Spinbox(self, from_=0, to=23, wrap=True, textvariable=self.hourstr, width=4, font=tkFont.Font(family=main_font, size=size_font), state="readonly") self.minstr = tk.StringVar(self, datetime.datetime.today().minute) self.minstr.trace("w", self.trace_var) self.last_value = "" self.min = tk.Spinbox(self, from_=0, to=59, wrap=True, textvariable=self.minstr, width=4, font=tkFont.Font(family=main_font, size=size_font), state="readonly") self.hour.grid() self.min.grid(row=0, column=1)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.player1 = Player() self.player2 = ComputerPlayer() self.isOver = True self.initUI()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.submit_tog = True self.initUI() self.text.bind_class("Text", "<Control-a>", self.selectall)
def __init__(self, master, d_list, a_function): Frame.__init__(self, master) scrl_bar = Scrollbar(self) self.listbox = Listbox(self) scrl_bar.config(command=self.listbox.yview) scrl_bar.pack(side=RIGHT, fill=Y) self.listbox.config(yscrollcommand=scrl_bar.set) self.listbox.pack(side=LEFT, expand=YES, fill=BOTH) #load the listbox idx = 0 for item in d_list: fparts = item.split('.') # DEBUG print fparts if fparts[-1] == 'csv': self.listbox.insert(idx, item) idx += 1 # link double click to the processList self.listbox.bind('<Double-1>', self.processList) # attach a function passed form the master # not this si done as passd function so it could be anything self.passed_function = a_function
def __init__(self, master): Frame.__init__(self, master) self.master = master self.initGUI() self.usbport = USBport()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.quote = "I was supposed to be a cool quote . But then internet abandoned me !" self.author = "Aditya" self.project = [{"name":"Portfolio","location": "F:\git\portfolio","command": "http://localhost:8080"},{"name":"JStack","location":"F:\git\JStack" ,"command": "http://localhost:8080"},{"name":"GPS_Track","location": "F:\git\GPS_Track","command": "http://localhost:8080"}] self.getQuote()
def __init__(self,parent,api,id): Frame.__init__(self, parent) self.parent = parent self.api = api self.id = id self.anySearch = False self.initUI()
def initUI(self): #some aesthetic definitions self.parent.title("Message Responder") self.style = Style() self.style.theme_use("classic") #building frame frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) #adding some widgets label = Label(frame, text = self.text, wraplength = 495, justify = LEFT) label.pack() self.textBox = Text(frame, height = 2, width = 495) self.textBox.pack(side = BOTTOM) #self.textBox.insert(END, '#enter ye comments here') labelBox = Label(frame, text = "Actual Results:") labelBox.pack(anchor = W, side = BOTTOM) passButton = Button(self, text="PASS", command=self.btnClickedPass) passButton.pack(side=RIGHT, padx=5, pady=5) failButton = Button(self, text="FAIL", command=self.btnClickedFail) failButton.pack(side=RIGHT)
class binaryErosionApp: def __init__(self, parent): self.parent = parent self.frame = Frame(self.parent) self.parent.title("Binary Erosion") self.initUI() def initUI(self): #Create 3x3 Grid for columns in range(0, 3): self.parent.columnconfigure(columns, pad = 14) for rows in range(0, 3): self.parent.rowconfigure(rows, pad = 14) #Add Noise Options binaryErosion1 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 1", command = self.binaryErosion1Clicked) binaryErosion2 = Button(self.frame, width = 10, height = 3, padx = 10, pady = 10, wraplength = 60, text = "Binary Erosion 2", command = self.binaryErosion2Clicked) binaryErosion1.grid(row = 1, column = 1, padx = 10, pady = 10, sticky = 'w') binaryErosion2.grid(row = 1, column = 2, padx = 10, pady = 10, sticky = 'w') self.frame.pack() def binaryErosion1Clicked(self): global _img, red, green, blue structure = zeros((20, 20)) structure[range(20), range(20)] = 1.0 red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0) green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0) blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0) for a in range(0, _img.shape[0]): for b in range(0, _img.shape[1]): _img[a, b, 0] = (red[a, b] * 255.0).astype('uint8') _img[a, b, 1] = (green[a, b] * 255.0).astype('uint8') _img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8') updateImage() def binaryErosion2Clicked(self): global _img, red, green, blue structure = zeros((20, 20)) structure[range(20), range(20)] = 1.0 red = where(red[:,:] > 255.0 * 0.6, 1.0, 0.0) green = where(green[:,:] > 255.0 * 0.6, 1.0, 0.0) blue = where(blue[:,:] > 255.0 * 0.6, 1.0, 0.0) red = ndimage.binary_erosion(red, structure) green = ndimage.binary_erosion(green, structure) blue = ndimage.binary_erosion(blue, structure) for a in range(0, _img.shape[0]): for b in range(0, _img.shape[1]): _img[a, b, 0] = (red[a, b] * 255.0).astype('uint8') _img[a, b, 1] = (green[a, b] * 255.0).astype('uint8') _img[a, b, 2] = (blue[a, b] * 255.0).astype('uint8') updateImage()
def init_ui(self): self.connections = {} self.button_frame = Frame(self) self.button_frame.grid(row=0, column=0, columnspan=2) self.map_frame = Frame(self) self.map_frame.grid(row=1, column=0, padx=5, pady=5) self.picker_frame = Frame(self) self.picker_frame.grid(row=1, column=1) self.button_new = Button(self.button_frame) self.button_new["text"] = "New" self.button_new["command"] = self.new_map self.button_new.grid(row=0, column=0, padx=2) self.open = Button(self.button_frame) self.open["text"] = "Open" self.open["command"] = self.open_map self.open.grid(row=0, column=1, padx=2) self.save = Button(self.button_frame) self.save["text"] = "Save" self.save["command"] = self.save_map self.save.grid(row=0, column=2, padx=2) self.get_map_list() self.map_list.grid(row=0, column=3, padx=2)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller label = Label(self, text="About", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label.pack(side="top", fill="x", pady=10) label_2 = Label(self, text= """ Frogs vs Flies is a cool on-line multi-player game. It consists of hungry frogs, trying to catch some darn tasty flies to eat and not starve to death, and terrified, but playful flies that try to live as long as possible to score points by not being eaten by nasty frogs. ---------------------------------------------------------------------------------------- When the game has been selected or created, and your class selected, click in the game field to start feeling your limbs. To move, use your keyboard's arrows. By this point, you should know where they are located, don't you? Great! Now you can start playing the game! ---------------------------------------------------------------------------------------- Frogs, being cocky little things, have the ability to do a double jump, holding SHIFT while moving with cursors. And flies, being so fly, that the air can't catch up with them, have a greater field of view, so they can see frogs before they can see them. ---------------------------------------------------------------------------------------- Have a wonderful time playing this awesome game! ---------------------------------------------------------------------------------------- Created by Kristaps Dreija and Egils Avots in 2015 Fall """, font=ABOUT_FONT, anchor=CENTER, justify=CENTER) label_2.pack() button1 = Button(self, text="\nBack\n", command=lambda: controller.show_frame("StartPage")) button1.pack(ipadx=20,pady=10)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.selected = ""; self.controller = controller label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label.pack(side="top", fill="x", pady=10) self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose) button2 = Button(self, text="Refresh", command=self.callback_refresh) button3 = Button(self, text="Back", command=self.callback_start) scrollbar = Scrollbar(self) self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set ) self.mylist.bind("<Double-Button-1>", self.twoClick) self.button1.pack() button2.pack() button3.pack() # create list with a scroolbar scrollbar.pack( side = "right", fill="y" ) self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 ) scrollbar.config( command = self.mylist.yview ) # create a progress bar label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center') label2.pack(side="top", fill="x") self.bar_lenght = 200 self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate') self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10) self.pb.config(value=0)
def initplayer(self): self.parentframe = Frame(self) self.parentframe.pack(fill=BOTH, expand=True) self.videoFrame = Frame(self.parentframe, width=800, height=480) self.videoFrame.pack(side="top", fill="both", expand=True) self.buttonframe = Frame(self.parentframe, padding="2 2 1 1") self.buttonframe.pack(side="bottom", fill="x", expand=False) self.seekbar = Scale(self.buttonframe, from_= 0, to=100, orient=HORIZONTAL) self.seekbar.grid(column=0, columnspan=4, row=0, sticky=[N, E, S, W]) self.seekbar.configure(command=self.seeked) self.selectbutton = Button(self.buttonframe, text="Select File") self.selectbutton.grid(column=0, row=1, sticky=[E,W]) self.streambutton = Button(self.buttonframe, text="Open HTTP", command=self.streamopen) self.streambutton.grid(column=1, row=1, sticky=[E,W]) self.playbutton = Button(self.buttonframe, text="Play") self.playbutton.config(command=self.playpause) self.playbutton.grid(column=2, row=1, sticky=[E,W]) self.fullscreenbutton = Button(self.buttonframe, text="Fullscreen", command=self.togglefullscreen) self.fullscreenbutton.grid(column=3, row=1, sticky=[E,W]) for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5) self.buttonframe.rowconfigure(0, weight=1) self.buttonframe.rowconfigure(1, weight=1) self.buttonframe.columnconfigure(0, weight=1) self.buttonframe.columnconfigure(1, weight=1) self.buttonframe.columnconfigure(2, weight=1) self.buttonframe.columnconfigure(3, weight=1) self.selectbutton.configure(command=self.fileopen) self.videoFrame.bind("<Button-1>",self.playpause) self.parent.bind("<F11>", self.togglefullscreen) self.parent.bind("<Motion>",self.mouseops)
def _create_help_tab(self, n): #================================== # Help tab layer_b1 = Frame(n) layer_b1.pack(side=TOP) explain = [ """ β: measure of relative risk of the stock with respect to the market (S&P500)\n. α: measure of the excess return with respect to the benchmark. Eq: R_i^stock="α"+"β x " R_i^market+ε_i R2: measure of how well the the returns of a stock is explained by the returns of the benchmark. Volatility: Standard deviation of the returned stocks Momentum: measure of the past returns over a certain period of time. More details @ http://gouthamanbalaraman.com/blog/calculating-stock-beta.html """ ] definition = LabelFrame(layer_b1, text="Definitions:") definition.pack(side=TOP, fill=BOTH) lbl = Label(definition, wraplength='10i', justify=LEFT, anchor=N, text=''.join(explain)) lbl.pack(anchor=NW) msg = [ """ Created by Sandeep Joshi for class FE520 Under guidance of Prof. Peter Lin @Stevens 2015 Special thanks to following people/ resources on the net: • Sentdex @Youtube • http://gouthamanbalaraman.com/blog/calculating-stock-beta.html • http://www.johnwittenauer.net/a-simple-time-series-analysis-of-the-sp-500-index/ • http://francescopochetti.com/category/stock-project/ • Moshe from SO -> http://stackoverflow.com/users/875832/moshe """ ] credits = LabelFrame(layer_b1, text="Credits:") credits.pack(side=TOP, fill=BOTH) lbl = Label(credits, wraplength='10i', justify=LEFT, anchor=S, text=''.join(msg)) lbl.pack(anchor=NW) n.add(layer_b1, text="Help/ Credits", underline=0, padding=2)
def initUI(self): self.parent.title("Simple") self.style = Style() self.style.theme_use("default") self.textup = Text(self, width=340, height=34) self.textup.bind("<KeyPress>", lambda e: "break") self.textup.pack() self.frame = Frame(self, relief=RAISED, borderwidth=1) self.frame.pack(fill=BOTH, expand=1) self.pack(fill=BOTH, expand=1) Label(self.frame,text = '', width= "350", height="1").pack() Label(self.frame,text = '欢迎大家', width= "350", height="1").pack() Label(self.frame,text = '', width= "350", height="3").pack() self.text = Text(self, width=340, height=3) self.text.bind("<Return>", self.sendMes) self.text.pack() closeButton = Button(self, text="Close") closeButton.pack(side=RIGHT, padx=5, pady=5) okButton = Button(self, text="OK", command=self.onClick) okButton.pack(side=RIGHT)
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand=1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) #okButton = Button(self, text = "OK") #okButton.place(x = self.width - 200, y = self.height - 100) #quitButton = Button(self.parent, text = "QUIT", command = self.endCommand) #quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize((self.width, self.height)) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image=self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x=0, y=0) info_x = int(self.width * scale) + 20
def __init__(self, master, item_width, item_height, item_relief=None, item_borderwidth=None, item_padding=None, item_style=None, offset_x=0, offset_y=0, gap=0, **kwargs): kwargs["width"] = item_width+offset_x*2 kwargs["height"] = offset_y*2 Frame.__init__(self, master, **kwargs) self._item_borderwidth = item_borderwidth self._item_relief = item_relief self._item_padding = item_padding self._item_style= item_style self._item_width = item_width self._item_height = item_height self._offset_x = offset_x self._offset_y = offset_y self._left = offset_x self._top = offset_y self._right = self._offset_x + self._item_width self._bottom = self._offset_y self._gap = gap self._index_of_selected_item = None self._index_of_empty_container = None self._list_of_items = [] self._position = {} self._new_y_coord_of_selected_item = None
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.quote = "I was supposed to be a cool quote . But then internet abandoned me !" self.author = "Aditya" self.initUI()
def __init__(self, searcher, master=None): """ Creates a window with a quit button and a ListFrame for each search term list, all linked to the given searcher. """ Frame.__init__(self, master) self.pack() self.exit = Button(self) self.exit['text'] = "Quit" self.exit['command'] = self.quit self.exit.grid(row=0) self.hashtags = ListFrame("Hashtags", searcher.add_hashtag, searcher.remove_hashtag, master=self) self.hashtags.grid(row=1, column=0, padx=5) self.users = ListFrame("Users", searcher.add_user, searcher.remove_user, master=self) self.users.grid(row=1, column=1, padx=5) self.excluded_words = ListFrame("Excluded Words", searcher.exclude_word, searcher.remove_excluded_word, master=self) self.excluded_words.grid(row=1, column=2, padx=5) self.excluded_words = ListFrame("Excluded Users", searcher.exclude_user, searcher.remove_excluded_user, master=self) self.excluded_words.grid(row=1, column=3, padx=5)
def _setup_breakpoint_list(self): self.breakpoints_frame = Frame(self.content) self.breakpoints_frame.grid(column=0, row=0, sticky=(N, S, E, W)) self.file_notebook.add(self.breakpoints_frame, text='Breakpoints') self.breakpoints = BreakpointView(self.breakpoints_frame, normalizer=self.filename_normalizer) self.breakpoints.grid(column=0, row=0, sticky=(N, S, E, W)) # The tree's vertical scrollbar self.breakpoints_scrollbar = Scrollbar(self.breakpoints_frame, orient=VERTICAL) self.breakpoints_scrollbar.grid(column=1, row=0, sticky=(N, S)) # Tie the scrollbar to the text views, and the text views # to each other. self.breakpoints.config(yscrollcommand=self.breakpoints_scrollbar.set) self.breakpoints_scrollbar.config(command=self.breakpoints.yview) # Setup weights for the "breakpoint list" tree self.breakpoints_frame.columnconfigure(0, weight=1) self.breakpoints_frame.columnconfigure(1, weight=0) self.breakpoints_frame.rowconfigure(0, weight=1) # Handlers for GUI events self.breakpoints.tag_bind('breakpoint', '<Double-Button-1>', self.on_breakpoint_double_clicked) self.breakpoints.tag_bind('breakpoint', '<<TreeviewSelect>>', self.on_breakpoint_selected) self.breakpoints.tag_bind('file', '<<TreeviewSelect>>', self.on_breakpoint_file_selected)
def initUI(self): crawlVar = IntVar() scanVar = IntVar() dnsVar = IntVar() emailVar = IntVar() self.filename = StringVar() self.parent.title("E-Z Security Audting") self.style = Style() self.style.theme_use("default") frame = Frame(self, borderwidth=1) frame.pack(side=TOP, fill=BOTH) self.pack(side=TOP, fill=BOTH) dnsButton = Checkbutton(self, text="DNS Recon", variable=dnsVar) dnsButton.pack(fill=X) scanButton = Checkbutton(self, text="Port Scan", variable=scanVar) scanButton.pack(fill=X) crawlButton = Checkbutton(self, text="Web Crawl", variable=crawlVar) crawlButton.pack(fill=X) emailButton = Checkbutton(self, text="Email Gathering", variable=emailVar) emailButton.pack(fill=X) lab = Label(self, width=15, text="Filename", anchor='w') ent = Entry(self,textvariable=self.filename) self.pack(side=TOP, fill=X, padx=5, pady=5) lab.pack(side=LEFT) ent.pack(side=RIGHT, fill=X)
def initUI(self): self.pack(fill=BOTH, expand=1) #create special frame for buttons at the top frame = Frame(self) frame.pack(fill=X) search = Entry(frame) def callback(): #create new window main(Search.SearchFrontPage(search.get())) b = Button(frame, text="Search", width=5, command=callback) b.pack(side=RIGHT) search.pack(side=RIGHT) def login(): #change login credentials self.credentials = reddituserpass.main() self.parent.destroy() login = Button(frame, text="Login", width=5, command=login) login.pack(side=LEFT) self.drawWindow()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.py = pydle() self._initUI()
def __init__(self, parent,multiplayer=False,HOST="99.66.147.56",PORT=3478,player=''): self.activeCard = 0 self.startTime = -1 self.multiplayer = multiplayer if self.multiplayer: self.client = KarutaClient(HOST, int(PORT), player) cards = self.client.cards self.cardsLeft = self.client.order else: self.client = KarutaSingleClient() cards = range(1,101) self.cardsLeft = range(1,101) random.shuffle(cards) random.shuffle(self.cardsLeft) self.queue = deque([]) self.fgrid = [[None for col in range(NUM_COLS)] for row in range(6)] self.model = [[None for col in range(NUM_COLS)] for row in range(6)] self.faultCount = 0 self.faults = [0,0] Frame.__init__(self, parent) self.parent = parent self.initUI(cards) self.changeState('waiting') if self.multiplayer: self.client.next = 0 self.opponentReady = False else: self.opponentReady = True self.client.nextMove = 0 self.pollForUpdates() self.processUpdates()
def initUI(self): self.parent.title("TKontact") self.style = Style() self.style.theme_use("default") # frame = Frame(self, relief=RAISED, borderwidth=1) # frame.pack(fill=BOTH, expand=1) # self.pack(fill=BOTH, expand=1) self.frame_left = Frame(self) self.frame_left.grid(row=0, column=0) self.frame_right = Frame(self) self.frame_right.grid(row=0, column=1) self.add_field("lastname") self.add_field("firstname") self.add_field("phone") self.add_button("add") self.add_button("open") self.add_button("delete") self.add_field("search") self.add_button("search") self.add_button("quit") self.add_contactlist() self.pack()
def initUI(self): self.frame_top = Frame(self) self.frame_graph = MplCanvas(self) self.frame_bottom = Frame(self) Label(self.frame_top, text='Z = ').pack(side=LEFT) self.spin_z = Spinbox(self.frame_top, from_=0, to=self.shape[2] - 1, increment=1, command=self.change_z) self.spin_z.pack(side=LEFT) self.make_checkbox(self.frame_bottom, width=4) Label(self.frame_top, text=' CSV').pack(side=LEFT) self.txt_filename_csv = Entry(self.frame_top) self.txt_filename_csv.pack(side=LEFT) self.button_read = Button(self.frame_top, text='Read', command=self.run_read) self.button_read.pack(side=LEFT) self.button_save = Button(self.frame_top, text='Save', command=self.run_save) self.button_save.pack(side=LEFT) Label(self.frame_top, text=' ').pack(side=LEFT) button_reset = Button(self.frame_top, text='Reset', command=self.reset).pack(side=LEFT) self.frame_top.pack(side=TOP) self.frame_graph.get_tk_widget().pack(fill=BOTH, expand=TRUE) self.frame_bottom.pack(fill=BOTH, expand=TRUE) self.pack(fill=BOTH, expand=True)
def initUI(self): #<standard set up> self.parent.title("Buttons") self.style = Style() self.style.theme_use("default") #</standard set up> #if you put buttons here, it will initiate the buttons. #then it will initiate the frame. You would get two columns. #buttons appear in the second "lowered" area and not the raised frame. #<adding an additional frame> frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand =1) #</adding an additional frame> #<standard self.pack> self.pack(fill=BOTH, expand =1) #</standard self.pack> #<buttons are placed here> closeButton = Button (self, text = "Close") closeButton.pack(side=RIGHT, padx=5, pady =5) okButton = Button(self, text = "OK") okButton.pack(side=RIGHT)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller ChooseType.socket = None ChooseType.create_player = None self.plx_name = "PLAYER" ChooseType.plx_type = "SPECTATOR" ChooseType.start_game = None label_1 = Label(self, text="Create character", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label_2 = Label(self, text="Name: ") self.entry_1 = Entry(self) self.entry_1.insert(0, 'Player_') label_3 = Label(self, text="Join as: ") button1 = Button(self, text="FROG", command=self.callback_frog) button2 = Button(self, text="FLY", command=self.callback_fly) button3 = Button(self, text="SPECTATOR", command=self.callback_spec) ChooseType.button4 = Button(self, text="Back", command=lambda: controller.show_frame("StartPage")) label_1.pack(side="top", fill="x", pady=10) label_2.pack() self.entry_1.pack() label_3.pack() button1.pack() button2.pack() button3.pack() ChooseType.button4.pack(pady=20)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI()
def __init__(self, parent): self.serialStatus = False #create variables self.startmotor = BooleanVar() self.logstate = BooleanVar() self.loggedData = [] self.throttlevar = StringVar() self.throttleval = IntVar() #default values self.throttlevar.set("0%") self.throttleval.set(0) #base frame init Frame.__init__(self, parent) self.parent = parent self.initUI() self.centerWindow() self.PERIOD_LENGTH_Log = 100 #milliseconds self.PERIOD_LENGTH_Scan = 1000 #milliseconds self.PERIOD_LENGTH_Refresh = 300 #milliseconds self.parent.after(0, self.runScan) self.parent.after(0, self.runLog) self.parent.after(0, self.runRefresh)
def checkbox(self, entry, value, options, group=None): """ Renders a checkbox input :param value: :param entry: :param options: :param group: :return: """ if group is None: group = self.root Btnframe = Frame(group) Btnframe.pack(side=LEFT) col = 0 for option in options: if isinstance(option, bool): option_text = 'No' if not option else 'Yes' else: option_text = option button = Radiobutton(Btnframe, text=option_text, padx=20, variable=entry, value=option) button.grid(row=0, column=col) if option == value: button.select() col += 1
def _add_filename(self, frame, index, name, mode, option): if option: self.function[-1] = lambda v: [option, v] else: self.function[-1] = lambda v: [v] self.variables[-1] = StringVar() var = self.variables[-1] def set_name(): if mode == "r": fn = tkFileDialog.askopenfilename(initialdir=".") else: fn = tkFileDialog.asksaveasfilename(initialdir=".") var.set(fn) label = Label(frame, text=name) label.grid(row=index, column=0, sticky="W", padx=10) field_button = Frame(frame) Grid.columnconfigure(field_button, 0, weight=1) field = Entry(field_button, textvariable=var) field.grid(row=0, column=0, sticky="WE") button = Button(field_button, text="...", command=set_name, width=1, padding=0) button.grid(row=0, column=1) field_button.grid(row=index, column=1, sticky="WE")
def populate(self): """ Renders form :return: """ row = 0 group = LabelFrame(self.scrolledFrame, padx=5, pady=5) group.pack(fill=X, padx=10, pady=10) for field_name, value in self.data.iteritems(): frame = Frame(group) frame.pack(anchor=N, fill=X) # Render label lab = Label(frame, width=15, text=field_name) lab.pack(anchor='w', side=LEFT, padx=2, pady=2) # Guess the entry type entry, var_type = self.get_type(value) # Convert list to comma separated string if var_type == 'list': value = ','.join(str(e) for e in value) # Build input if var_type == 'bool': self.checkbox(entry, value, options=[True, False], group=frame) else: self.input(entry, group=frame, value=value) if field_name in self.entries: self.entries[field_name] = (field_name, entry, var_type) else: self.entries.update( {field_name: (field_name, entry, var_type)}) row += 1
def initUI(self): #some aesthetic definitions self.parent.title("Message Responder") self.style = Style() self.style.theme_use("classic") #building frame frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) self.pack(fill=BOTH, expand=True) #adding some widgets label = Label(frame, text=self.text, wraplength=495, justify=LEFT) label.pack() self.textBox = Text(frame, height=2, width=495) self.textBox.pack(side=BOTTOM) #self.textBox.insert(END, '#enter ye comments here') labelBox = Label(frame, text="Actual Results:") labelBox.pack(anchor=W, side=BOTTOM) passButton = Button(self, text="PASS", command=self.btnClickedPass) passButton.pack(side=RIGHT, padx=5, pady=5) failButton = Button(self, text="FAIL", command=self.btnClickedFail) failButton.pack(side=RIGHT)
def startVid(self): gobject.threads_init() video = Frame(self, background='black') video.grid(row=0, column=0, columnspan=8, rowspan=4, padx=2, sticky=E+W+S+N) window_id = video.winfo_id() self.buf = gst.Buffer() self.bin = gst.Bin("my-bin") timeoverlay = gst.element_factory_make("timeoverlay", "overlay") self.bin.add(timeoverlay) pad = timeoverlay.get_pad("video_sink") ghostpad = gst.GhostPad("sink", pad) self.bin.add_pad(ghostpad) videosink = gst.element_factory_make("ximagesink") self.bin.add(videosink) gst.element_link_many(timeoverlay, videosink) self.player.set_property('video-sink', self.bin) self.player.set_property('uri', 'file://%s' % (os.path.abspath(self.project.videoPath))) bus = self.player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect("message", self.on_message, window_id) bus.connect('sync-message::element', self.on_sync_message, window_id) self.play.configure(command=lambda: self.play_video()) self.back.configure(command=self.play_back)
def insert_frame(self, name, parent_frame_name, idx, frame_type=None, **kwargs): parent_frame = self.frames[parent_frame_name] frame = Frame(parent_frame) # add frame to list of frames self.frames[name] = frame # pre-fill the frame if frame_type is None: pass elif frame_type == 'plot': # generate canvas dim = kwargs['shape'] f = Figure(figsize=dim, dpi=113 ) a = f.add_subplot(111) canvas = FigureCanvasTkAgg(f, master=frame) # Commit the canvas to the gui canvas.get_tk_widget().pack() # save canvas data for later access self.mpl_data[name] = {} self.frame_data['plot'] = {'mpl_canvas':canvas} # commit the frame to workspace frame.grid(row=idx[0], column=idx[1])
def initUI(self): self.parent.title("Mystery Room") self.pack(fill=BOTH, expand = 1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) #okButton = Button(self, text = "OK") #okButton.place(x = self.width - 200, y = self.height - 100) #quitButton = Button(self.parent, text = "QUIT", command = self.endCommand) #quitButton.place(x = self.width - 100, y = self.height - 100) scale = 0.75 self.wow_pic = Image.open("/home/pi/demo2/hd_1.jpg") self.wow_pic = self.wow_pic.resize((self.width, self.height)) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image = self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x = 0, y = 0) info_x = int(self.width*scale) + 20
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent # Spiral parameters (defined as StringVars for convenience) self.a = StringVar() self.a.set('0') self.b = StringVar() self.b.set('0.5') self.c = StringVar() self.c.set('1') self.lMax = StringVar() self.lMax.set(158) self.frec = StringVar() self.frec.set(500) self.StringLongitud = StringVar() self.StringRadio = StringVar() # Help mode flag self.ayuda = False # Figure object self.f = Figure(figsize=(5, 5)) self.initUI()
def initUI(self): self.parent.title("Test") self.frameTab = Frame(self, relief=RAISED, borderwidth=1) self.frameTab.grid(row=3, column=0, columnspan=4) self.grid(row=0, column=0) self.frameTab.grid(row=0, column=0) self.note_book = Notebook(self.frameTab) self.specific_actions = ActionModulation.ActionModulation(self.note_book) self.note_book.add(self.specific_actions.getFrame(), text="specific actions") self.general_actions = GeneralActionModulation.GeneralActionModulation(self.note_book) self.note_book.add(self.general_actions.getFrame(), text="general actions") self.note_book.grid(row=0, column=0) self.frameButtons = Frame(self, relief=RAISED, borderwidth=1) self.frameButtons.grid(row=3, column=0, columnspan=4) self.buttonReset = Button(self.frameButtons, text="Reset") self.buttonReset.grid(row=0, column=0) self.buttonAbort = Button(self.frameButtons, text="Abort") self.buttonAbort.grid(row=0, column=1) self.buttonStop = Button(self.frameButtons, text="Stop") self.buttonStop.grid(row=0, column=2) self.buttonSendAction = Button(self.frameButtons, text="Send Action") self.buttonSendAction.grid(row=0, column=4) self.buttonSendEmotion = Button(self.frameButtons, text="Send Emotion") self.buttonSendEmotion.grid(row=0, column=5)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller self.parent = parent Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10') self.columnconfigure(0, pad=10) self.columnconfigure(1, pad=10) self.rowconfigure(0, pad=10) self.rowconfigure(1, pad=10) self.rowconfigure(2, pad=10) self.btn_wifi = Button(self, text="Wifi Connection Demo", command=lambda: controller.show_frame("Test_Wifi"), width=BTN_WIDTH) self.btn_wifi.grid(row=1, column=0) self.btn_gps_3g = Button(self, text="3G + GPS Demo", command=lambda: controller.show_frame("Test_GPS3G"), width=BTN_WIDTH) self.btn_gps_3g.grid(row=1, column=1) self.btn_cepas = Button(self, text="Cepas Reader Demo", command=lambda: controller.show_frame("Test_Cepas"), width=BTN_WIDTH) self.btn_cepas.grid(row=2, column=0) self.btn_zebra_scanner = Button(self, text="Zebra Scanner Demo", command=lambda: controller.show_frame("Test_ZebraScanner"), width=BTN_WIDTH) self.btn_zebra_scanner.grid(row=2, column=1) self.pack()
def initUI(self): self.parent.title("Example") self.pack(fill=BOTH, expand=1) self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=1) okButton = Button(self, text="OK") okButton.place(x=self.width - 200, y=self.height - 100) quitButton = Button(self.parent, text="QUIT") quitButton.place(x=self.width - 100, y=self.height - 100) scale = 0.75 self.wow_pic = Image.open("hd_1.jpg") self.wow_pic = self.wow_pic.resize( (int(self.width * scale), int(self.height * scale))) self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic) self.label_wow_pic = Label(self, image=self.wow_pic_tk) self.label_wow_pic.image = self.wow_pic_tk self.label_wow_pic.place(x=10, y=10) info_x = int(self.width * scale) + 20 label_text_area = Tkinter.Label(self, text="Message received:") label_text_area.place(x=info_x, y=10) self.text_area = Tkinter.Text(self, height=10, width=40) self.text_area.place(x=info_x, y=30)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.u = utils('atoutput.pkl') self.km = dict() self.price = dict() self.km[0] = (min(self.u.all_km), max(self.u.all_km)) self.price[0] = (min(self.u.all_price), max(self.u.all_price)) self.zoom_level = 0 try: self.parent.title("Auto trader results") self.is_standalone = True except: self.is_standalone = False self.style = Style() self.style.theme_use("classic") # Assume the parent is the root widget; make the frame take up the # entire widget size. print self.is_standalone if self.is_standalone: self.w, self.h = map(int, self.parent.geometry().split('+')[0].split('x')) self.w, self.h = 800, 800 else: self.w, self.h = 600, 600 self.c = None # Are they hovering over a data point? self.is_hovering = False # Filter the description strings: lower and whiten any non-matching # data point. self.filter = '' self.re = list() self.replot()
def __init__(self, parent): Frame.__init__(self, parent) self.lock = threading.Lock() self.parent = parent self.NUM_SPEAKERS = 5 self.initUI() self.num_inserted = []
def _setup_stack_frame_list(self): self.stack_frame = Frame(self.content) self.stack_frame.grid(column=0, row=0, sticky=(N, S, E, W)) self.file_notebook.add(self.stack_frame, text='Stack') self.stack = StackView(self.stack_frame, normalizer=self.filename_normalizer) self.stack.grid(column=0, row=0, sticky=(N, S, E, W)) # # The tree's vertical scrollbar self.stack_scrollbar = Scrollbar(self.stack_frame, orient=VERTICAL) self.stack_scrollbar.grid(column=1, row=0, sticky=(N, S)) # # Tie the scrollbar to the text views, and the text views # # to each other. self.stack.config(yscrollcommand=self.stack_scrollbar.set) self.stack_scrollbar.config(command=self.stack.yview) # Setup weights for the "stack" tree self.stack_frame.columnconfigure(0, weight=1) self.stack_frame.columnconfigure(1, weight=0) self.stack_frame.rowconfigure(0, weight=1) # Handlers for GUI events self.stack.bind('<<TreeviewSelect>>', self.on_stack_frame_selected)
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.current_image = posts[0] self.posts = posts self.initUI() self.current_booru = None
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.centerWindow() self.initUI()
def __init__(self, master, track, sequencer): TrackFrame.__init__(self, master, track) self.id_label = Label(self, text=str(track.id)) self.id_label.pack(side='left') self.instrument_label = Label(self, text=str(track.instrument_tone), width=3) self.instrument_label.pack(side='left') mute_var = IntVar() self.mute_toggle = Checkbutton(self, command=lambda: check_cmd(track, mute_var), variable=mute_var) self.mute_toggle.pack(side='left') mute_var.set(not track.mute) rhythm_frame = Frame(self) rhythm_frame.pack(side='right') subdivision = sequencer.measure_resolution / sequencer.beats_per_measure self.buttons = [] for b in range(0, len(self.track.rhythms)): button = RhythmButton(rhythm_frame, track, b, not b % subdivision) self.buttons.append(button) button.grid(row=0, column=b, padx=1) self.beat = 0
def __init__(self, parent, tile_size, grid_vm=None): Frame.__init__(self, parent, relief=RAISED, borderwidth=1) self.parent = parent self.tile_size = tile_size self.grid_vm = grid_vm self.columnconfigure(0, weight=1) self.columnconfigure(1, pad=3) self.rowconfigure(0, weight=1) self.rowconfigure(1, pad=3) hbar = Scrollbar(self, orient=HORIZONTAL) vbar = Scrollbar(self, orient=VERTICAL) canvas = Canvas(self, xscrollcommand=hbar.set, yscrollcommand=vbar.set) self.canvas = canvas self.lines = [] canvas.bind_all("<MouseWheel>", self._on_mousewheel_vertical) canvas.bind_all("<Shift-MouseWheel>", self._on_mousewheel_horizontal) # Set up scroll bars hbar.pack(side=BOTTOM, fill=X) hbar.config(command=canvas.xview) vbar.pack(side=RIGHT, fill=Y) vbar.config(command=canvas.yview) canvas.grid(column=0, row=0, sticky=N + W + E + S) hbar.grid(column=0, row=1, sticky=W + E) vbar.grid(column=1, row=0, sticky=N + S) if grid_vm: self.set_vm(grid_vm)
def init_ui(self): self.connections = {} self.button_frame = Frame(self) self.button_frame.grid(row=0, column=0, columnspan=2) self.map_frame = Frame(self) self.map_frame.grid(row=1, column=0, padx=5, pady=5, sticky=N + S + E + W) self.picker_frame = Frame(self) self.picker_frame.grid(row=1, column=1) self.button_new = Button(self.button_frame) self.button_new["text"] = "New" self.button_new["command"] = self.new_map self.button_new.grid(row=0, column=0, padx=2) self.menubar = Menu(self) menu = Menu(self.menubar, tearoff=0) self.menubar.add_cascade(label="File", menu=menu) menu.add_command(label="New") menu.add_command(label="Open") menu.add_command(label="Save") self.open = Button(self.button_frame) self.open["text"] = "Open" self.open["command"] = self.open_map self.open.grid(row=0, column=1, padx=2) self.save = Button(self.button_frame) self.save["text"] = "Save" self.save["command"] = self.save_map self.save.grid(row=0, column=2, padx=2) self.get_map_list() self.map_list.grid(row=0, column=3, padx=2)
def initUI(self): self.parent.title("MyStock") self.style = Style() self.style.theme_use("default") frame = Frame(self, relief=RAISED, borderwidth=1) frame.pack(fill=BOTH, expand=True) menubar = Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Menu(menubar) fileMenu.add_command(label="Exit", command=self.onExit) menubar.add_cascade(label="File", menu=fileMenu) submenu= Menu(fileMenu) submenu.add_command(label="New feed") submenu.add_command(label="Bookmarks") submenu.add_command(label="Mail") fileMenu.add_cascade(label='Import', menu=submenu, underline=0) fileMenu.add_separator() closeButton = Button(self, text="Close", command=self.quit) closeButton.pack(side=RIGHT, padx=5, pady=5) okButton = Button(self, text="OK") okButton.pack(side=RIGHT) self.pack(fill=BOTH, expand=1) self.centerWindow()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.parent.title("Twitter Judge") self.style = Style() self.style.theme_use("default") output_frame = Frame(self, relief = RIDGE, borderwidth = 1) output_frame.pack(anchor = N, fill = BOTH, expand = True) output_text = ScrolledText(output_frame) self.output_text = output_text output_text.pack(fill = BOTH, expand = True) input_frame = Frame(self, height = 32) input_frame.pack(anchor = S, fill = X, expand = False) user_label = Label(input_frame, text = "Enter username:"******"Judge!", command = lambda: judge(user_entry.get(), self)) judge_button.pack(side = RIGHT) user_entry = Entry(input_frame) user_entry.pack(fill = X, padx = 5, pady = 5, expand = True) self.pack(fill = BOTH, expand = True)
def __init__(self, parent, agent): Frame.__init__(self, parent) self.parent = parent self.agent = agent self.parent.title("Hunt The Wumpus - F. Liuzzi") self.button = Button(parent, text="Step Agent", command=self.moveAgent) self.button.pack() self.canvas_height = 64 * (self.agent.rows+1) + 64 self.canvas_width = 64 * (self.agent.cols+1) #if self.agent.rows == self.agent.cols: # self.canvas_height += 64 self.canvas = Canvas(parent, width=self.canvas_width, height=self.canvas_height) #traverse agent map to display appropriate pictures self.drawGameGrid() self.canvas.pack() self.pack()
def __init__(self, parent, receipt): self.curr_upc = "" self.receipt = receipt self.title = "Scan" self.root = Frame(parent) self.prompt = "Scan Item to Add\n it to Your Cart" self.label = tk.Label(self.root, text=self.prompt, font=("Helvetica", 26), anchor=tk.CENTER, bg=Scan.bg_color, pady=170) self.text = tk.Text(self.root, height=1, width=1, fg=Scan.bg_color, bg=Scan.bg_color, highlightcolor=Scan.bg_color, insertbackground=Scan.bg_color) self.text.bind("<Key>", self.create_upc) self.text.bind("<Return>", self.callback) self.root.bind("<Visibility>", self.on_visibility) self.text.focus_set() self.text.pack() self.label.pack()