class ticketViews(): def __init__(self, parent, id): self.client = client = httplib2.Http( disable_ssl_certificate_validation=True) self.client.add_credentials(username, password) ## Pull View Name self.viewResp, self.viewContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.viewData = json.loads(self.viewContent) print repr(self.viewData) self.countResp, self.countContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + "/count.json") self.viewResp, self.viewContent = client.request( "https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.countData = json.loads(self.countContent) print repr(self.countContent) self.parent = parent print(self.parent.winfo_width()) self.label = Label(text=self.viewData["view"]["title"] + " " + str(self.countData["view_count"]["value"])) self.label.pack(fill=BOTH)
def initUI(self): self.parent.title("Buttons") self.style = Style() self.style.theme_use("alt") # Styling self.style.configure('.', font=('Helvetica', 12), background="#300A24") self.style.configure( "PW.TLabel", foreground="#fff", background="#300A24", padding=20, justify=CENTER, wraplength="350") self.style.configure( "Medium.TButton", foreground="#300A24", background="#fff", borderwidth=0, padding=8, font=('Helvetica', 9)) # Styling Ends quoteLabel = Label(self, text=self.quote, style="PW.TLabel") quoteLabel.pack() authorLabel = Label(self, text=self.author, style="PW.TLabel") authorLabel.pack() self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Close This", style="Medium.TButton", command=self.parent.quit) closeButton.pack(side=RIGHT) okButton = Button( self, text="Portfolio", style="Medium.TButton", command=self.btnOneFn) okButton.pack(side=RIGHT) okButton = Button(self, text="JStack", style="Medium.TButton", command=self.btnTwoFn) okButton.pack(side=RIGHT) okButton = Button(self, text="Python", style="Medium.TButton", command=self.btnThreeFn) okButton.pack(side=RIGHT)
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)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Scale") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) scale = Scale(self, from_=0, to=100, command=self.onScale) scale.pack(side=LEFT, padx=15) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack(side=LEFT) def onScale(self, val): v = int(float(val)) self.var.set(v)
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 __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)
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("ListBox") self.pack(fill=BOTH, expand=1) eagles = ["Sam Bradford", "Jordan Matthews", "LeBron James", "Donnie Jones"] lb = Listbox(self) for i in eagles: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.pack(pady=15) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack() def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
def initUI(self): self.parent.title("Buttons") self.style = Style() self.style.theme_use("alt") # Styling self.style.configure('.', font=('Helvetica', 12), background="#300A24") self.style.configure( "PW.TLabel", foreground="#fff", background="#300A24", padding=20, justify=CENTER, wraplength="350") self.style.configure( "Medium.TButton", foreground="#300A24", background="#fff", borderwidth=0, padding=8, font=('Helvetica', 9)) # Styling Ends quoteLabel = Label(self, text=self.quote, style="PW.TLabel") quoteLabel.pack() authorLabel = Label(self, text=self.author, style="PW.TLabel") authorLabel.pack() self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Close This", style="Medium.TButton", command=self.parent.quit) closeButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[0]["name"], style="Medium.TButton", command=lambda: self.btnFn(0)) projectButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[1]["name"], style="Medium.TButton", command=lambda: self.btnFn(1)) projectButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[2]["name"], style="Medium.TButton", command=lambda: self.btnFn(2)) projectButton.pack(side=RIGHT)
def showHighscores(): # get top 5 scores arr = session.query(Highscores).all() for i in range(len(arr)): for j in range(i, len(arr)): if (arr[i].score > arr[j].score): arr[i], arr[j] = arr[j], arr[i] top = Toplevel() top.title('Highscores') msg = Message(top, text='Top 5 Leaderboard:') msg.pack count = 1 for i in range(5): text = str(count) text += '. ' text += str(arr[i].name) text += ': ' text += str(arr[i].score) label = Label(top, text=text) label.pack() count += 1 button = Button(top, text='Dismiss', command=top.destroy) button.pack() top.geometry('%dx%d+%d+%d' % (200, 200, 600, 300))
def img_label(self, path="cat1.jpeg"): window = Toplevel() #window.geometry('400x400') window.title('image') img = ImageTk.PhotoImage(Image.open(path)) label = Label(window, image=img) label.pack() window.mainloop()
class Login(Frame): """******** Funcion: __init__ ************** Descripcion: Constructor de Login Parametros: self Login parent Tk Retorno: void *****************************************************""" def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() """******** Funcion: initUI ************** Descripcion: Inicia la interfaz grafica de un Login, para ello hace uso de Frames y Widgets. Parametros: self Login Retorno: void *****************************************************""" def initUI(self): self.parent.title("Pythagram: Login") self.style = Style() self.style.theme_use("default") self.frame = Frame(self, relief=RAISED) self.frame.pack(fill=BOTH, expand=1) self.instructions = Label(self.frame,text="A new Web Browser window will open, you must log-in and accept the permissions to use this app.\nThen you have to copy the code that appears and paste it on the next text box.") self.instructions.pack(fill=BOTH, padx=5,pady=5) self.codeLabel = Label(self.frame,text="Code:") self.codeLabel.pack(fill=BOTH, padx=5,pady=5) self.codeEntry = Entry(self.frame) self.codeEntry.pack(fill=BOTH, padx=5,pady=5) self.pack(fill=BOTH, expand=1) self.closeButton = Button(self, text="Cancel", command=self.quit) self.closeButton.pack(side=RIGHT, padx=5, pady=5) self.okButton = Button(self, text="OK", command=self.login) self.okButton.pack(side=RIGHT) """******** Funcion: login ************** Descripcion: Luego que el usuario ingresa su codigo de acceso, hace la solicitud al servidor para cargar su cuenta en una ventana de tipo Profile Parametros: self Retorno: Retorna... *****************************************************""" def login(self): code = self.codeEntry.get() api = InstagramAPI(code) raw = api.call_resource('users', 'info', user_id='self') data = raw['data'] self.newWindow = Toplevel(self.parent) global GlobalID GlobalID = data['id'] p = Profile(self.newWindow,api,data['id'])
class gui(Frame): def __init__(self,master=Tk()): Frame.__init__(self,master) self.grid() self.image = Image.open("test.jpg") self.photo = PhotoImage(self.image) self.label = Label(master,image=self.photo) self.label.image = photo self.label.pack()
def pack_text(self, text, frame=None): """adds some label text in the desired location""" if frame is None: label = Label(self.window, text=text) else: label = Label(frame, text=text) label.pack()
def bigger_preview(): image = Image.open( get_image_from_internet_binary( u"%s%s" % (main_url, self.current_image[u"file_url"]))) photo = ImageTk.PhotoImage(image) self.bigpreview = Toplevel(self) labelu = Label(self.bigpreview, image=photo) labelu.image = photo labelu.pack(fill=Y, expand=0, side=LEFT)
def initUI(self): self.parent.title("Test the Gauss point") self.pack(fill=BOTH, expand=True) self.fields = \ 'bulk_modulus', \ 'scale_hardening', \ 'max_stress_in', \ 'increment_strain', \ 'Nloop', \ 'initial_confinement', \ 'reference_pressure', \ 'modulus_n', \ 'cohesion', \ 'RMC_shape_k', \ 'dilation_angle_eta', \ 'diletion_scale' default_values = \ '1E7', \ '1E3', \ '3E4', \ '1E-4', \ '2', \ '1E5', \ '1E5', \ '0.7', \ '0.0', \ '1.0', \ '1.0', \ '1.0' # ================== # Entries for User input: self.entries = [] for idx, field in enumerate(self.fields): row = Frame(self) row.pack(fill=X) labl = Label(row, text=field, width=30) labl.pack(side=LEFT, padx=5, pady=5) entry = Entry(row) entry.insert(END, default_values[idx]) entry.pack(fill=X, padx=5, expand=True) self.entries.append((field, entry)) # print field # ================== # Button for calculation frameButtonCalc = Frame(self) frameButtonCalc.pack(fill=X) calcButton = Button(frameButtonCalc, text="calculate", command=self.calculate) calcButton.pack(side=LEFT, padx=5, pady=5) # ================== # Raw Frame for plot self.canvasFrame = Frame(self) self.canvasFrame.pack(fill=BOTH, expand=True)
class gui(Frame): def __init__(self, master=Tk()): Frame.__init__(self, master) self.grid() self.image = Image.open("test.jpg") self.photo = PhotoImage(self.image) self.label = Label(master, image=self.photo) self.label.image = photo self.label.pack()
def timer_widget(self): """ Make the time lable. """ l = Label(self, textvariable=self.timestr, background="White", font=('Helvetica', 32), anchor='center', relief='sunken') self._set_time(self._elapsedtime) l.pack(fill=X, expand=NO, pady=50, padx=50)
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Title", width=6) lbl1.pack(side=LEFT, padx=5, pady=5) entry1 = Entry(frame1) entry1.pack(fill=X, padx=5, expand=True)
def initUI(self): self.parent.title("Simple FTP-Client") self.pack(fill=BOTH, expand=True) # self.parent.title("Buttons") #frame2 = Frame(self) #frame2.pack(anchor=W,side=LEFT) #lbl2 = Label(frame2, text="Command Line", width=6) #lbl2.pack(fill=X,anchor=W,expand=True,padx=5, pady=5) #txt2 = Text(frame2) #txt2.pack(fill=X,side=BOTTOM,pady=5, padx=5) frame3 = Frame(self, width=400, height=500) frame3.pack(side=BOTTOM,anchor=NW) lbl3 = Label(frame3, text="Command Line", width=6) lbl3.pack(fill=X,anchor=NE,expand=True,padx=5, pady=5) txt = Text(frame3) txt.pack(fill=BOTH,pady=5, padx=5) wid = frame3.winfo_id() os.system('xterm -into %d -geometry 400x400 -sb &' % wid) f1 = Frame(self) f1.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10) lb=Label(f1, text="Host:").grid(row=0, column=0) e1 = Entry(f1) e1.grid(row=0, column=1, padx=1) f2 = Frame(self) f2.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10) lb2=Label(f2, text="Username:"******"Password:"******"Port:").grid(row=0, column=2) e4 = Entry(f4) e4.grid(row=0, column=3, padx=5) connectButton = Button(self, text="Connect", command=callback) connectButton.pack(expand=True,fill=X,side=LEFT, anchor=NW, padx=10, pady=10)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller #create label label = Label(self, text="Welcome to\n\nFrogs vs Flies!\n", font=TITLE_FONT, justify=CENTER, anchor=CENTER) label.pack(side="top", fill="x", pady=10) #create buttons button1 = Button(self, text="\nCreate a new game\n", command=lambda: controller.show_frame("CreateServer")) button2 = Button(self, text="\nJoin game\n", command=lambda: controller.show_frame("FindServer")) button3 = Button(self, text="\nAbout\n", command=lambda: controller.show_frame("AboutPage")) #place buttons in the frame button1.pack(ipadx=100,pady=10) button2.pack(ipadx=117,pady=10) button3.pack(ipadx=40,pady=10)
def initUI(self): self.parent.title("Buttons") self.style = Style() self.style.theme_use("alt") # Styling self.style.configure('.', font=('Helvetica', 12), background="#300A24") self.style.configure("PW.TLabel", foreground="#fff", background="#300A24", padding=20, justify=CENTER, wraplength="350") self.style.configure("Medium.TButton", foreground="#300A24", background="#fff", borderwidth=0, padding=8, font=('Helvetica', 9)) # Styling Ends quoteLabel = Label(self, text=self.quote, style="PW.TLabel") quoteLabel.pack() authorLabel = Label(self, text=self.author, style="PW.TLabel") authorLabel.pack() self.pack(fill=BOTH, expand=True) closeButton = Button(self, text="Close This", style="Medium.TButton", command=self.parent.quit) closeButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[0]["name"], style="Medium.TButton", command=lambda: self.btnFn(0)) projectButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[1]["name"], style="Medium.TButton", command=lambda: self.btnFn(1)) projectButton.pack(side=RIGHT) projectButton = Button(self, text=self.project[2]["name"], style="Medium.TButton", command=lambda: self.btnFn(2)) projectButton.pack(side=RIGHT)
def loadScriptPage(self): # Button States self.parent.prevButton.config(state='disabled') if self.parent.scriptname != '': self.parent.nextButton.config(state='normal') explain = Label(self, text=txt.selectscript, justify=CENTER, font=root.fontH1) explain.pack(pady=50) self.loadedscript = Label(self, text=self.parent.scriptname, justify=CENTER, font=root.fontH1) self.loadedscript.pack() loadscriptBtn = Button(self, text="Load Script", command=self.getScript) loadscriptBtn.pack(pady=10)
def initUI(self): self.parent.title("Pythagram: Search") self.style = Style() self.style.theme_use("default") self.frame = Frame(self,relief=RAISED) self.frame.pack(fill=BOTH, expand=1) searchLabel = Label(self.frame, text="Search") self.searchEntry = Entry(self.frame) searchLabel.pack(fill=BOTH, padx=5,pady=5) self.searchEntry.pack(fill=BOTH, padx=5,pady=5) self.pack(fill=BOTH, expand=1) okButton = Button(self, text="OK", command=self.search) okButton.pack(side=RIGHT, padx=5, pady=5)
def popupWindowStaleMate(self, msg): popup = tk.Tk() popup.wm_attributes("-topmost", 1) popup.focus_force() popup.wm_title("End of Game!") label = Label(popup, text=msg, font=("Helvetica", 16), anchor=tk.CENTER, relief='groove') label.pack(side="top", fill="x", pady=10) B1 = Button(popup, text="?????? Start New Game ??????", command=lambda popup=popup: self.endOfGameButton(popup)) B1.pack() popup.mainloop()
def UIinit(self): self.parent.title('Warning') self.pack(fill=BOTH, expand=1) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Are you sure you want to exit the \nexperiment?") lbl1.pack(side=LEFT, padx=5, pady=5) frame2 = Frame(self) frame2.pack(fill=X) button1 = Button(frame2, text="Yes", command=self.yes) button1.pack(side=LEFT, padx=5, pady=5) button2 = Button(frame2, text="No", command=self.stay) button2.pack(padx=5,pady=5)
class ticketViews(): def __init__(self, parent, id): self.client = client = httplib2.Http(disable_ssl_certificate_validation=True) self.client.add_credentials(username, password) ## Pull View Name self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.viewData = json.loads(self.viewContent) print repr(self.viewData) self.countResp, self.countContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + "/count.json") self.viewResp, self.viewContent = client.request("https://rackspacecloud.zendesk.com/api/v2/views/" + str(id) + ".json") self.countData = json.loads(self.countContent) print repr(self.countContent) self.parent = parent print(self.parent.winfo_width()) self.label = Label(text=self.viewData["view"]["title"] + " " + str(self.countData["view_count"]["value"])) self.label.pack(fill=BOTH)
def main1(): main_window = Tk() main_window.geometry("500x500") main_window.iconbitmap(os.path.abspath( os.curdir + "\Assets\Alien_robot.ico")) #r"C:\Users\ofer\Desktop\github files\project\Alien_robot.ico") main_window.wm_title("Personal Helper!") l = Label(text="Personal helper!") CheckVal1 = IntVar() w = Checkbutton(main_window, text="work", variable=CheckVal1, \ onvalue=1, offvalue=0, height=5, \ width=20) b = Button(main_window, text="start scanning for programs", command=scan_computer_programs) #c = Button(main_window, text="block all gaming apps", command=running_programs(main_window,True)) l.pack() b.pack() c.pack() w.pack() print CheckVal1 main_window.mainloop()
def init_ui(root): root.geometry("500x500+500+500") f = Frame(root) f.pack(fill=BOTH, expand=True) frame1 = Frame(f) frame1.pack(fill=X) lbl1 = Label(frame1, text="Enter url here", width=6) lbl1.pack(side=LEFT, padx=5, pady=5) entry1 = Entry(frame1) entry1.pack(fill=X, padx=5, expand=True) frame3 = Frame(f) frame3.pack(fill=X) lbl3 = Label(frame3, text="Keywords", width=6) lbl3.pack(side=LEFT, anchor=N, padx=5, pady=5) txt = Text(frame3) txt.pack(fill=BOTH, pady=5, padx=5, expand=True) def on_click(): url = entry1.get() print url keywords = get_keywords(url) res = ", ".join(keywords) print res txt.delete("1.0", END) txt.insert("1.0", res) def on_click2(): entry1.delete(0, END) frame2 = Frame(f) frame2.pack(fill=X) tk.Button(frame2, text="Get keywords", command=on_click).pack() tk.Button(frame2, text="Clear", command=on_click2).pack()
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Your Speed Is:", width=18, font=("Helvetica", 16)) lbl1.pack(padx=5, pady=5) frame2 = Frame(self) frame2.pack(fill=X) mph = Label(frame2, text="MPH", width=6, font=("Helvetica", 20)) mph.pack(side=RIGHT, padx=5, pady=5) self.speed_text = StringVar() speed_label = Label(frame2, textvariable = self.speed_text, width = 18, font=("Helvetica", 60)) speed_label.pack(fill=X, padx=5, expand=True) frame3 = Frame(self) frame3.pack(fill=BOTH, expand=True) self.v = StringVar() self.v.set("Late For Class?") self.speed = Label(frame3, textvariable=self.v, width=16, font=("Helvetica", 40)) self.speed.pack(padx=5, pady=5) def updateMetrics(self,speed,message): formatted_speed = "{0:.2f}".format(speed) self.speed_text.set(formatted_speed) print str("{0:.2f}".format(speed))
def initUI(self): self.parent.title("Test the Gauss point") self.pack(fill=BOTH, expand=True) self.fields = \ 'bulk_modulus', \ 'Scale_Hardening', \ 'max_strain_in', \ 'increment_strain', \ 'Nloop' default_values = \ '16750', \ '1', \ '1E-2', \ '1E-4', \ '0' # ================== # Entries for User input: self.entries = [] for idx, field in enumerate(self.fields): row = Frame(self) row.pack(fill=X) labl = Label(row, text=field, width=30) labl.pack(side=LEFT, padx=5, pady=5) entry = Entry(row) entry.insert(END, default_values[idx]) entry.pack(fill=X, padx=5, expand=True) self.entries.append((field, entry)) # print field # ================== # Button for calculation frameButtonCalc = Frame(self) frameButtonCalc.pack(fill=X) calcButton = Button(frameButtonCalc, text="calculate", command=self.calculate) calcButton.pack(side=LEFT, padx=5, pady=5) # ================== # Raw Frame for plot self.canvasFrame = Frame(self) self.canvasFrame.pack(fill=BOTH, expand=True)
def initUI(self): self.parent.title("Drawing Window") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=True) frameL = Frame(self, relief=RAISED, borderwidth=2) frameL.pack(fill=BOTH, expand=True) lbMax = Label(frameL, text="Maximum Arrangment", width=25) lbMax.pack(side=TOP, padx=5, pady=5) canvas = Canvas(frameL) canvas.create_rectangle(30, 10, 120, 80, outline="#fff", fill="#fff") frameR = Frame(self, relief=RAISED, borderwidth=2) frameR.pack(fill=BOTH, expand=True) lbMin = Label(frameR, text="Minimum Arrangment", width=25) lbMin.pack(side=TOP, padx=5, pady=5) quitButton = Button(self, text="Quit", command=self.quit) quitButton.pack(side=RIGHT, padx=10, pady=10)
class Handle(Frame): def __init__(self, panedwindow, sash_index, disallow_dragging=False, on_click=None, **kw): image = kw.pop("image", None) Frame.__init__(self, panedwindow, class_="Handle", **kw) self._sash_index = sash_index if image: self._event_area = Label(self, image=image) self._event_area.pack() else: self._event_area = self self._center = int(self._event_area.winfo_reqwidth() / 2), int( self._event_area.winfo_reqheight() / 2) if disallow_dragging: if on_click: self._event_area.bind('<Button-1>', lambda event: on_click()) else: self._event_area.bind('<Button-1>', self._initiate_motion) self._event_area.bind('<B1-Motion>', self._on_dragging) self._event_area.bind('<ButtonRelease-1>', self.master._on_release) def _initiate_motion(self, event): self.master._active_sash = self._sash_index self._dx = event.x self._dy = event.y @property def sash_index(self): return self._sash_index def _on_dragging(self): raise NotImplementedError
class Window(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("WORLD") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) #pack = a geometry manager #button b = Button(self, text=" GO ", command=self.callback) b.pack(side=TOP, padx=15, pady=20) #text t = Text(self, height=3, width=40) t.pack(side=TOP, padx=15) t.insert( END, "Welcome.\nPlease select the number of years\nyou would like to run the Simulation.\n" ) #slider slider = Scale(self, from_=0, to=400, command=self.onScale) #values of slider! slider.pack(side=TOP, padx=15) self.var = IntVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack(side=TOP, padx=15) def onScale(self, val): v = int(float(val)) self.var.set(v) def callback(self): print("CLICK!")
class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent self.initUI() def initUI(self): self.parent.title("Listbox") self.pack(fill=BOTH, expand=1) acts = ['Scarlett Johansson', 'Rachel Weiss', 'Natalie Portman', 'Jessica Alba', 'Someone Else'] with open('test.txt', 'rb') as f: lb = Listbox(self) for i in f: lb.insert(END, i) lb.bind("<<ListboxSelect>>", self.onSelect) lb.pack(pady=15) self.var = StringVar() self.label = Label(self, text=0, textvariable=self.var) self.label.pack() def onSelect(self, val): sender = val.widget idx = sender.curselection() value = sender.get(idx) self.var.set(value)
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Your Speed Is:", width=18, font=("Helvetica", 16)) lbl1.pack(padx=5, pady=5) frame2 = Frame(self) frame2.pack(fill=X) mph = Label(frame2, text="MPH", width=6, font=("Helvetica", 20)) mph.pack(side=RIGHT, padx=5, pady=5) self.speed_text = StringVar() speed_label = Label(frame2, textvariable = self.speed_text, width = 18, font=("Helvetica", 60)) speed_label.pack(fill=X, padx=5, expand=True) frame3 = Frame(self) frame3.pack(fill=BOTH, expand=True) self.v = StringVar() self.v.set("Late For Class?") self.speed = Label(frame3, textvariable=self.v, width=16, font=("Helvetica", 40)) self.speed.pack(padx=5, pady=5)
class PreferencesDialog(Dialog): def __init__(self, parent, title, font, size): self._master = parent self.result = False self.font = font self.size = size Dialog.__init__(self, parent, title) def body(self, master): self._npFrame = LabelFrame(master, text='Annotation window text') self._npFrame.pack(fill=X) self._fontFrame = Frame(self._npFrame, borderwidth=0) self._fontLabel = Label(self._fontFrame, text='Font:', width=5) self._fontLabel.pack(side=LEFT, padx=3) self._fontCombo = Combobox(self._fontFrame, values=sorted(families()), state='readonly') self._fontCombo.pack(side=RIGHT, fill=X) self._sizeFrame = Frame(self._npFrame, borderwidth=0) self._sizeLabel = Label(self._sizeFrame, text='Size:', width=5) self._sizeLabel.pack(side=LEFT, padx=3) self._sizeCombo = Combobox(self._sizeFrame, values=range(8, 15), state='readonly') self._sizeCombo.pack(side=RIGHT, fill=X) self._fontFrame.pack() self._sizeFrame.pack() self._npFrame.pack(fill=X) self._fontCombo.set(self.font) self._sizeCombo.set(self.size) def apply(self): self.font = self._fontCombo.get() self.size = self._sizeCombo.get() self.result = True def cancel(self, event=None): if self.parent is not None: self.parent.focus_set() self.destroy()
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) lbl1 = Label(frame1, text="Title", width=6) lbl1.pack(side=LEFT, padx=5, pady=5) entry1 = Entry(frame1) entry1.pack(fill=X, padx=5, expand=True) frame2 = Frame(self) frame2.pack(fill=X) lbl2 = Label(frame2, text="Author", width=6) lbl2.pack(side=LEFT, padx=5, pady=5) entry2 = Entry(frame2) entry2.pack(fill=X, padx=5, expand=True) frame3 = Frame(self) frame3.pack(fill=BOTH, expand=True) lbl3 = Label(frame3, text="Review", width=6) lbl3.pack(side=LEFT, anchor=N, padx=5, pady=5) txt = Text(frame3) txt.pack(fill=BOTH, pady=5, padx=5, expand=True)
class RhythmTrackFrame(TrackFrame): 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 set_time(self, beat): self.buttons[self.beat].playing = False self.buttons[self.beat].toggle_visual() self.beat = beat self.buttons[self.beat].playing = True self.buttons[self.beat].toggle_visual() def destroy(self): return TrackFrame.destroy(self)
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)
class AudioFader(Frame): def __init__(self, master, get_gain, set_gain, label=''): Frame.__init__(self, master, width=FADER_WIDTH, height=FADER_HEIGHT) self.get_gain = get_gain self._set_gain = set_gain if isinstance(label, StringVar): Label(self, textvar=label, width=15).pack() else: Label(self, text=label, width=15).pack() self.gain_label = Label(self) gain_scale = Scale(self, from_=1, to=0, command=self.set_gain, orient='vertical') gain_scale.set(self.get_gain()) gain_scale.pack() self.gain_label.pack() def set_gain(self, value): gain = float(value) self._set_gain(gain) self.gain_label.config(text='%1.2f' % gain)
def main1(): main_window = Tk() main_window.geometry("500x500") main_window.iconbitmap( os.path.abspath(os.curdir + "\Assets\Alien_robot.ico") ) #r"C:\Users\ofer\Desktop\github files\project\Alien_robot.ico") main_window.wm_title("Personal Helper!") l = Label(text="Personal helper!") CheckVal1 = IntVar() w = Checkbutton(main_window, text="work", variable=CheckVal1, \ onvalue=1, offvalue=0, height=5, \ width=20) b = Button(main_window, text="start scanning for programs", command=scan_computer_programs) #c = Button(main_window, text="block all gaming apps", command=running_programs(main_window,True)) l.pack() b.pack() c.pack() w.pack() print CheckVal1 main_window.mainloop()
def __init__(self, parent, rows=8, columns=8, size=64, color1="white", color2="lightgreen", oldColor='',\ firstSquare=' ',secondSquare=' '): self.rows = rows self.columns = columns self.size = size # size is individual square size in pixels self.color1 = color1 # light color, ie white self.color2 = color2 # dark color, ie darkgreen self.oldColor = oldColor # this holds the old square color for highlighting selected square self.firstSquare = firstSquare # holds first square clicked self.secondSquare = secondSquare # holds second square clicked self.nameToCoords = {} # {'wp3':(6,2)...} self.squaresToName = { } # this will map squares to pieces, {'c2':'wp3'...} # initialize underlying board class (does underlying game logic) self.board = lib.moveLogic.Board() canvas_width = columns * size canvas_height = rows * size tk.Frame.__init__(self, parent) label1 = Label(self) label1.pack() button1 = Button(label1, text="QUIT!", command=sys.exit) button1.pack(side=tk.LEFT) button2 = Button(label1, text="New Game", command=self.newGame) button2.pack(side=tk.LEFT) button3 = Button(label1, text="Undo Move", command=self.undoMove) button3.pack(side=tk.LEFT) self.canvas = tk.Canvas(self, borderwidth=0, highlightthickness=0, width=canvas_width, height=canvas_height) self.canvas.bind("<Button-1>", self.callBackLeftClick) self.canvas.pack(side="top", fill="both", expand=True, padx=0, pady=0) self.canvas.bind("<Configure>", self.refresh) self.board.newGame()
class PreferencesDialog(Dialog): def __init__(self, parent, title, font, size): self._master = parent self.result = False self.font = font self.size = size Dialog.__init__(self, parent, title) def body(self, master): self._npFrame = LabelFrame(master, text='Annotation window text') self._npFrame.pack(fill=X) self._fontFrame = Frame(self._npFrame, borderwidth=0) self._fontLabel = Label(self._fontFrame, text='Font:', width=5) self._fontLabel.pack(side=LEFT, padx=3) self._fontCombo = Combobox(self._fontFrame, values=sorted(families()), state='readonly') self._fontCombo.pack(side=RIGHT, fill=X) self._sizeFrame = Frame(self._npFrame, borderwidth=0) self._sizeLabel = Label(self._sizeFrame, text='Size:', width=5) self._sizeLabel.pack(side=LEFT, padx=3) self._sizeCombo = Combobox(self._sizeFrame, values=range(8,15), state='readonly') self._sizeCombo.pack(side=RIGHT, fill=X) self._fontFrame.pack() self._sizeFrame.pack() self._npFrame.pack(fill=X) self._fontCombo.set(self.font) self._sizeCombo.set(self.size) def apply(self): self.font = self._fontCombo.get() self.size = self._sizeCombo.get() self.result = True def cancel(self, event=None): if self.parent is not None: self.parent.focus_set() self.destroy()
def enter(self, event=None): bouding_box = self.widget.bbox("insert") if bouding_box == None: return x = bouding_box[0] y = bouding_box[1] cx = bouding_box[2] cy = bouding_box[3] x += self.widget.winfo_rootx() + 25 y += self.widget.winfo_rooty() + 20 self.top_window = Toplevel(self.widget) # Leaves only the label and removes the app window self.top_window.wm_overrideredirect(True) self.top_window.wm_geometry("+%d+%d" % (x, y)) label = Label(self.top_window, text=self.text, justify='left', background="white", relief='solid', borderwidth=1, font=("times", "12", "normal")) label.pack(ipadx=1)
class AnimatedTextureModelInput(Frame): def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, relief=GROOVE, borderwidth=2) self.label_model = Label(self,text="model name") self.input_model = Text(self,height=1,width=30) self.tooltip_model = TooltipDecorator(self.input_model,"Model filename.") self.label_textures = Label(self,text="texture names") self.input_textures = Text(self,height=1,width=30) self.tooltip_textures = TooltipDecorator(self.input_textures,"Semicolon separated texture filenames.\nThe textures will be cycled through with specified framerate.") self.label_framerate = Label(self,text="texture framerate") self.input_framerate = Text(self,height=1,width=30) self.tooltip_framerate = TooltipDecorator(self.input_framerate,"How fast the textures will be changed.") self.label_model.pack() self.input_model.pack() self.label_textures.pack() self.input_textures.pack() self.label_framerate.pack() self.input_framerate.pack() def clear(self): self.input_model.delete("1.0",END) self.input_textures.delete("1.0",END) self.input_framerate.delete("1.0",END) ## Returns list of texture names. def get_textures(self): text = self.input_textures.get("1.0",END).replace("\n","") return text.split(";") def get_model(self): text = self.input_model.get("1.0",END).replace("\n","") return text def get_framerate(self): text = self.input_framerate.get("1.0",END).replace("\n","") try: return float(text) except Exception: return 1.0 ## Fills the widget with info from given model. def set_model(self,animated_texture_model): self.clear() self.input_model.insert("1.0",animated_texture_model.model_name) self.input_textures.insert("1.0",list_to_string(animated_texture_model.texture_names)) self.input_framerate.insert("1.0",animated_texture_model.framerate) ## Sets the properties of given model by values in the widget. def fill_model(self,animated_texture_model): animated_texture_model.model_name = self.get_model() animated_texture_model.texture_names = self.get_textures() animated_texture_model.framerate = self.get_framerate()
def initUI(self): self.parent.title("Software Activation") self.style = Style() self.style.theme_use("default") self.pack(fill=BOTH, expand=1) if(self.needsActivated()): idEntry = Entry(self, width=36) idEntry.place(x=175, y=20) idEntry.delete(0, END) idEntry.insert(0, "Enter a product id") keyEntry = Entry(self, width=36) keyEntry.place(x=175, y=40) keyEntry.delete(0, END) keyEntry.insert(0, "Enter your license key") activateButton = Button(self, text="Activate", command=lambda:self.activate( idEntry.get(), keyEntry.get())) activateButton.place(x=250, y=65) else: label = Label(self, text="Product has already been activated") label.pack()
class Handle(Frame): def __init__(self, panedwindow, sash_index, disallow_dragging=False, on_click=None, **kw): image = kw.pop("image", None) Frame.__init__(self, panedwindow, class_="Handle", **kw) self._sash_index = sash_index if image: self._event_area = Label(self, image=image) self._event_area.pack() else: self._event_area = self self._center = int(self._event_area.winfo_reqwidth()/2), int(self._event_area.winfo_reqheight()/2) if disallow_dragging: if on_click: self._event_area.bind('<Button-1>', lambda event: on_click()) else: self._event_area.bind('<Button-1>', self._initiate_motion) self._event_area.bind('<B1-Motion>', self._on_dragging) self._event_area.bind('<ButtonRelease-1>', self.master._on_release) def _initiate_motion(self, event) : self.master._active_sash = self._sash_index self._dx = event.x self._dy = event.y @property def sash_index(self): return self._sash_index def _on_dragging(self): raise NotImplementedError
def promoteBlackPopup(self, msg): popup = tk.Tk() popup.wm_attributes("-topmost", 1) popup.focus_force() popup.wm_title("Promote!") blackRook = tk.PhotoImage(master=popup, file='res/br.gif') blackKnight = tk.PhotoImage(master=popup, file='res/bn.gif') blackBishop = tk.PhotoImage(master=popup, file='res/bb.gif') blackQueen = tk.PhotoImage(master=popup, file='res/bq.gif') label = Label(popup, text=msg, font=("Helvetica", 16), anchor=tk.CENTER, relief='groove') label.pack(side="top", fill="x", pady=10) B1 = Button( popup, image=blackRook, command=lambda popup=popup: self.promoteChoice('br', popup)) B1.pack(side=tk.LEFT) B2 = Button( popup, image=blackBishop, command=lambda popup=popup: self.promoteChoice('bb', popup)) B2.pack(side=tk.LEFT) B3 = Button( popup, image=blackKnight, command=lambda popup=popup: self.promoteChoice('bn', popup)) B3.pack(side=tk.LEFT) B4 = Button( popup, image=blackQueen, command=lambda popup=popup: self.promoteChoice('bq', popup)) B4.pack(side=tk.LEFT) popup.mainloop()
def set_cropping(self): if not self.cropping: self.cropping = True self.cropButton.config(text="Save Crop") self.BWButton.config(state=tk.DISABLED) self.RButton.config(state=tk.DISABLED) else: self.cropTop = tk.Toplevel(width=200, height=100) self.cropTop.title("Confirm crop") self.cropTop.resizable(width=None, height=None) label = Label(self.cropTop, text="Crop the image?", pad=5) label.pack() confirm = Button(self.cropTop, text="Confirm", pad=5, command=self.crop_image) confirm.pack(pady=5, padx=5) cancel = Button(self.cropTop, text="Cancel", pad=5, command=self.cancel_crop_top) cancel.pack(pady=5, padx=5) self.BWButton.config(state=tk.NORMAL) self.RButton.config(state=tk.NORMAL)
def initUI(self): self.parent.title("Review") self.pack(fill=BOTH, expand=True) labelfont20 = ('Roboto', 20, 'bold') labelfont12 = ('Roboto', 12, 'bold') frame0 = Frame(self) frame0.pack() lbl0 = Label(frame0, text="Hi USER") lbl0.config(font=labelfont20) lbl0.pack(padx=5, pady=5) lbl00 = Label(frame0, text="Search here") lbl00.config(font=labelfont12) lbl00.pack(padx=5, pady=5) frame1 = Frame(self) frame1.pack() lbl1 = Label(frame1, text="min %", width=9) lbl1.pack(side=LEFT, padx=7, pady=5) self.entry1 = Entry(frame1, width=20) self.entry1.pack(padx=5, expand=True) frame6 = Frame(self) frame6.pack() closeButton = Button(frame6, text="Get Names", width=12, command=self.getDate) closeButton.pack(padx=5, pady=5) frame7 = Frame(self) frame7.pack() closeButton1 = Button(frame7, text="Open in excel", width=15, command=self.openDate) closeButton1.pack(padx=5, pady=5) frame000 = Frame(self) frame000.pack() self.lbl000 = Label(frame000, text=" ") self.lbl000.config(font=labelfont12) self.lbl000.pack(padx=5, pady=5) frame00a = Frame(self) frame00a.pack() self.lbl00a = Label(frame000, text=" ") self.lbl00a.pack(padx=5, pady=5)
def init_ui(self): self.parent_.title('Rough surface generator') self.pack(fill=BOTH, expand=True) # top panel with controls frame_top = Frame(self, background=self.TOP_FRAME_BACKGROUND_COLOR) frame_top.pack(fill=X) self.cb = Combobox(frame_top, values=('Gaussian', 'Laplace')) self.cb.current(0) self.cb.pack(side=LEFT, padx=5, expand=True) l1 = Label(frame_top, text=r'Cx', background=self.TOP_FRAME_BACKGROUND_COLOR, width=4) l1.pack(side=LEFT, padx=5, expand=True) self.entry1 = Entry(frame_top, validate='key', validatecommand=(self.register(self.on_validate), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W'), width=10) self.entry1.pack(side=LEFT, padx=5, expand=True) self.entry1.insert(0, str(self.a_)) l1 = Label(frame_top, text=r'Cy', width=4, background=self.TOP_FRAME_BACKGROUND_COLOR) l1.pack(side=LEFT, padx=5) self.entry2 = Entry(frame_top, validate='key', validatecommand=(self.register(self.on_validate), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W'), width=10) self.entry2.pack(side=LEFT, padx=5, expand=True) self.entry2.insert(0, str(self.b_)) but1 = Button(frame_top, text='RUN', command=self.button_action) but1.pack(side=RIGHT, padx=5, pady=5) # central panel. It will have a label with an image. Image may have a random noise state, or # transformed image state self.img_frame.pack(fill=BOTH, expand=True) img_label = Label(self.img_frame, background=None) img_label.pack(expand=True, fill=BOTH, padx=5, pady=5)
def initUI(self): self.master.title("Telegram UnlimitMe") self.master.minsize(width=500, height=300) self.pack(fill=BOTH, expand=True) frame1 = Frame(self) frame1.pack(fill=X) tknlbl = Label(frame1, text="Token", width=7, font=("Helvetica", 10)) tknlbl.pack(side=LEFT, padx=5, pady=5) tkntxt = Entry(frame1, font=("Helvetica", 10)) tkntxt.pack(fill=X, padx=5, expand=True) tkntxt.insert(0, self.loadtoken()) frame2 = Frame(self) frame2.pack(fill=X) cidlbl = Label(frame2, text="Chat ID", width=7, font=("Helvetica", 10)) cidlbl.pack(side=LEFT, padx=5, pady=5) cidtxt = Entry(frame2, font=("Helvetica", 10)) cidtxt.pack(fill=X, padx=5, expand=True) cidtxt.insert(0, self.loadcid()) frame3 = Frame(self) frame3.pack(fill=X) msglbl = Label(frame3, text="Message", width=8, font=("Helvetica", 10)) msglbl.pack(side=LEFT, anchor=N, padx=5, pady=5) msgtxt = Entry(frame3, width=30, font=("Helvetica", 10)) msgtxt.insert( 0, "UnlimitMe script by (Gooogle)[https://github.com/GooogIe/UnlimitMe]" ) msgtxt.pack(fill=BOTH, padx=5, pady=2) frame8 = Frame(self) frame8.pack(fill=X) tmslbl = Label(frame8, text="Spam times", width=10, font=("Helvetica", 10)) tmslbl.pack(side=LEFT, anchor=N, padx=5, pady=5) tmstxt = Entry(frame8, width=30, font=("Helvetica", 10)) tmstxt.insert(0, "5") tmstxt.pack(fill=BOTH, padx=5, pady=2) frame7 = Frame(self) frame7.pack(fill=X) imglbl = Label(frame7, text="Image Source", width=15, font=("Helvetica", 10)) imglbl.pack(side=LEFT, anchor=N, padx=5, pady=5) imgtxt = Entry(self, width=30, font=("Helvetica", 10)) imgtxt.insert(0, "http://www.photo.it/ok.png") imgtxt.pack(fill=BOTH, padx=5, pady=2) frame4 = Frame(self) frame4.pack(fill=X) x = StringVar() x.set("Chat IDS found: \n" + str(chatids(tkntxt.get()))) cidslbl = Label(frame4, textvariable=x, width=40, font=("Helvetica", 10)) cidslbl.pack(side=LEFT, anchor=N, padx=5, pady=5) listbox = Listbox(frame4, width=30, font=("Helvetica", 10)) listbox.pack(side=RIGHT, padx=5, pady=5) frame5 = Frame(self) frame5.pack(fill=X) spambtn = Button(frame5, relief=FLAT, bg="#1EFE7B", text="Spam", font=("Helvetica", 10), fg="#ffffff", width=15, command=lambda: self.flood(tmstxt.get(), msgtxt.get( ), tkntxt.get(), cidtxt.get())) spambtn.pack(side=RIGHT, padx=5, pady=5) sendbtn = Button( frame5, relief=FLAT, bg="#2ECC71", text="Send", font=("Helvetica", 10), fg="#ffffff", width=15, command=lambda: self.sendMessage(msgtxt.get(), tkntxt.get( ), cidtxt.get()) & listbox.insert(END, "You: " + msgtxt.get())) sendbtn.pack(side=RIGHT, padx=5, pady=5) imgbtn = Button(frame5, relief=FLAT, bg="#1ABC9C", text="Send a Photo", font=("Helvetica", 10), fg="#ffffff", width=15, command=lambda: self.sendImage(imgtxt.get( ), tkntxt.get(), cidtxt.get())) imgbtn.pack(side=LEFT, padx=5, pady=5) savebtn = Button( frame5, relief=FLAT, bg="#E74C3C", text="Save CID & Token", font=("Helvetica", 10), fg="#ffffff", width=15, command=lambda: self.saveall(tkntxt.get(), cidtxt.get())) savebtn.pack(side=LEFT, padx=5, pady=5) getcidsbtn = Button(frame5, relief=FLAT, bg="#3498DB", text="Reload Chat IDS", font=("Helvetica", 10), fg="#ffffff", width=15, command=lambda: x.set("Chat IDS found: \n" + chatids(tkntxt.get()))) getcidsbtn.pack(side=LEFT, padx=5, pady=5) frame6 = Frame(self) frame6.pack(fill=X, expand=True) abtlbl = Label( frame6, font=("Helvetica", 10), text="Created by Habb0n - (c) 2016 - Using Python & Tkinter", width=50) abtlbl.pack(side=BOTTOM, anchor=N, padx=1, pady=1)
class Window(Frame): def __init__(self, parent): Frame.__init__(self, parent) self.initUI() self.UIwithGrid() def initUI(self): # creating gui self.frame1 = Frame(self) self.frame2 = Frame(self) self.frame3 = Frame(self) self.frame4 = Frame(self) self.frame5 = Frame(self) # created multiple frames self.label1 = Label(self.frame1, text="COURSE PROGRAM ESTIMATOR", font='Helvetica 25 bold', background="SpringGreen3", foreground="black") self.label2 = Label(self.frame1, text=" Training Data: ", font="Times 14") self.entry = Entry(self.frame1, width=65) self.entry.insert( 0, 'https://www.sehir.edu.tr/tr/duyurular/2017-2018-Akademik-Yili-Ders-Programi' ) self.color = Label( self.frame1, text=" ", background="red", ) self.button = Button(self.frame1, text="Fetch and Train", command=self.fetch) self.label3 = Label(self.frame2, text="Individual Courses:", font='Helvetica 10 bold') self.label4 = Label(self.frame3, text=" Top 3 Estimates:", font='Helvetica 10 bold') self.coursesListbox = Listbox(self.frame2, width=30) self.label5 = Label(self.frame4, text=" Accuracy Analysis \nBased on Programs: ", font='Helvetica 10 bold') self.programsListbox = Listbox(self.frame4, width=30) self.estimatesListbox = Text(self.frame5, width=30, height=10) self.scrollbar1 = Scrollbar(self.frame2, orient=VERTICAL) self.scrollbar2 = Scrollbar(self.frame4, orient=VERTICAL) self.scrollbar3 = Scrollbar(self.frame5, orient=VERTICAL) self.scrollbar1.config(command=self.coursesListbox.yview) self.scrollbar2.config(comman=self.programsListbox.yview) self.scrollbar3.config(command=self.estimatesListbox.yview) self.coursesListbox.config(yscrollcommand=self.scrollbar1.set) self.programsListbox.config(yscrollcommand=self.scrollbar2.set) self.estimatesListbox.config(yscrollcommand=self.scrollbar3.set) def UIwithGrid(self): self.frame1.grid(row=1, column=2, sticky=N + S + E + W) self.frame2.grid(row=2, column=1, columnspan=2, sticky=W) self.frame3.grid(row=2, column=2, sticky=N + E) self.frame4.grid(row=3, column=1, columnspan=2, sticky=W, pady=5) self.frame5.grid(row=3, column=2, columnspan=2, sticky=E, pady=5) self.label1.grid(row=1, column=2, sticky=E + W) self.label2.grid(row=2, column=1, columnspan=2, pady=25, sticky=W) self.entry.grid(row=2, column=2, columnspan=2, sticky=E) self.color.grid(row=3, column=2, columnspan=2) self.button.grid(row=3, column=2, sticky=E, padx=90) self.label3.grid(row=1, column=1) self.coursesListbox.grid(row=2, column=1) self.label4.pack(in_=self.frame3, side='left') self.label5.grid(row=1, column=1) self.programsListbox.grid(row=2, column=1) self.estimatesListbox.grid(row=2, column=3, sticky=E) self.scrollbar1.grid(row=2, column=1, sticky=N + S + E) self.scrollbar2.grid(row=2, column=1, sticky=N + E + S) self.scrollbar3.grid(row=2, column=2, columnspan=2, sticky=N + S + E) self.pack() def fetch(self): # fetching phase self.color.config(background='yellow') self.course_list = [] self.update() url = self.entry.get() self.dataobj = Data() # creating data obj self.dataobj.init_data(url) self.courses = self.dataobj.courselist.keys() # getting keys self.courses.sort() # sorting keys self.obj_list = [] for i in self.courses: self.obj_list.append(self.dataobj.courselist[i]) self.classifier_obj = docclass.naivebayes(docclass.getwords) for i in self.obj_list: # TRANING PHASE self.classifier_obj.train(i.split_name.lower(), i.first_code) r1 = re.compile("(.*?)\s*\(") for i in self.courses: # adding courses to listbox course_name = self.dataobj.courselist[i].name name = r1.match(course_name) if name != None: name1 = i + '' + '(' + name.group(1) + ')' else: name1 = i + ' ' + '(' + course_name + ')' self.coursesListbox.insert(END, name1) for z in self.courses: # adding course category to other listbox if self.dataobj.courselist[z].first_code not in self.course_list: self.course_list.append(self.dataobj.courselist[z].first_code) code = self.dataobj.courselist[z].first_code if code not in self.programsListbox.get(0, END): self.programsListbox.insert(END, code) self.color.config(background='green') self.update() self.coursesListbox.bind('<<ListboxSelect>>', self.estimate) self.programsListbox.bind('<<ListboxSelect>>', self.analyze) def estimate(self, event): # estimating phase try: for wid in self.frame3.winfo_children(): wid.destroy() self.label4 = Label(self.frame3, text=" Top 3 Estimates:", font='Helvetica 10 bold') self.label4.pack(in_=self.frame3) except: print 'ERROR !!!!' widget = event.widget selection = widget.curselection() picked = widget.get(selection[0]) x = picked.split('(') dict_ = {} for cat in self.course_list: # getting estimating scores dict_[cat] = self.classifier_obj.prob(x[1], cat) * 10 scores = dict_ sorted_scores = sorted(scores.items(), key=operator.itemgetter(1), reverse=True) # sorting dictionary top_3 = sorted_scores[0:3] # getting top 3 scores print top_3 dict_temp = {x[0].split(' ')[0]: top_3} m = 1 for key, value in dict_temp.items(): # adding items as labels for i in value: department, score = i if department != key: # checking if it is true estimation or not color = 'red' else: color = 'green' self.first_element = Label(self.frame3, text=department + ':' + str(score), font='Helvetica 15 bold', background=color, width=20) if m == 1: self.first_element.pack(in_=self.frame3) elif m == 2: self.first_element.pack(in_=self.frame3) elif m == 3: self.first_element.pack(in_=self.frame3) m = m + 1 def analyze(self, event): try: self.estimatesListbox.delete('1.0', END) except: print 'ERROR' widget = event.widget selection = widget.curselection() picked = widget.get(selection[0]) cat_ = picked course_names = {} for i in self.obj_list: # creating a dict. keys name of courses, values code of if i.first_code == cat_: # filtering print i.first_code, cat_ name = i.name.split('(')[0] course_names[name] = i.code else: continue info = {} for course in course_names.keys(): # finds best match for each course score_dict = {} for cat in self.course_list: score_dict[cat] = self.classifier_obj.prob(course, cat) sorted_scores = sorted(score_dict.items(), key=operator.itemgetter(1), reverse=True) info[course] = sorted_scores[0][0] all_info = { 'Total Number Of Courses: ': str(len(info)) } # creating initial analyzing data q = 0 for item in info.values(): # amount of accurate data if item != cat_: q = q + 1 all_info['Inaccurate Classification: '] = str(q) all_info['Accurately Classified: '] = len(info) - q all_info['Accuracy: '] = '%' + str( (float(all_info['Accurately Classified: ']) / float(len(info))) * 100) _ = all_info.keys() _.sort() for infos in _: self.estimatesListbox.insert(END, infos + str(all_info[infos]) + '\n ') for course_ in info: self.estimatesListbox.insert( END, '\t' + course_names[course_] + '-->' + info[course_] + '\n')
class SearchVisualizerApp(Frame): def __init__(self, parent, speed=100, fname='map.txt', algo=uniform_cost_search, run=False, jump=False): Frame.__init__(self, parent) self.parent = parent self.path = None self.grid_view = None self.speed = speed self.algo = algo self.run = run self.jump = jump self.parent.title("Search Visualizer") self.style = Style().configure("TFrame", background="#333") self.tile_size = tile_size = 16 self.grid_view = Grid(self, self.tile_size) self.grid_view.pack(fill=BOTH, expand=True) self.grid_view.canvas.bind('<Button-1>', self._on_mouse_click) self.g = None self.h = None self.last_hover = None self.step_num = 0 self.load_map(fname) self.pack(fill=BOTH, expand=True) self.stepCounter = Label(self, text="Count: 000") self.stepCounter.pack(side=LEFT, padx=5, pady=5) self.algoLabel = Label(self, text="g: h: f:") self.algoLabel.pack(side=LEFT, padx=5, pady=5) # TODO Check boxes to select heuristic # TODO Button to select algorithm and restart quitButton = Button(self, text="Quit", command=self.quit) quitButton.pack(side=RIGHT, padx=5, pady=5) stepButton = Button(self, text="Step", command=self._step_button) stepButton.pack(side=RIGHT, padx=5, pady=5) pauseButton = Button(self, text="Start/Stop", command=self._pause_toggle) pauseButton.pack(side=RIGHT) jumpButton = Button(self, text="End", command=self._jump_button) jumpButton.pack(side=RIGHT, padx=5, pady=5) self.bind("<space>", self._pause_toggle) self.bind("<q>", self._quit) self.centerWindow() def _quit(self, event): self.quit() def _jump_button(self): self.run = False self.jump = True def _on_mouse_click(self, event): x, y = self.grid_view.canvas.canvasx( event.x), self.grid_view.canvas.canvasy(event.y) c, r = np.floor(x / self.tile_size), np.floor(y / self.tile_size) if (c, r) is self.last_hover: return self.last_hover = (c, r) tile_size = self.grid_view.tile_size grid_vm = self.grid_view.grid_vm (C, R) = grid_vm.shape if c >= C or r >= R: return s = grid_vm[c, r] if self.g and self.h: h = self.h(s) g = float("inf") if s in self.g: g = self.g[s] f = g + h self.algoLabel.configure( text="g: {0:5.2f} | h: {1:5.2f} | f: {2:5.2f}".format(g, h, f)) def _pause_toggle(self, event=None): self.run = not self.run if self.run: self.loop() def _step_button(self): self.run = False self.step() # Change the search generator to use def set_search(self, search): pass def load_map(self, fname): (grid, start, goal) = input_file(fname) grid_vm = np.array([TileVM(v) for v in grid.flatten()]).reshape(grid.shape) grid_vm[start].is_start = True grid_vm[goal].is_goal = True self.search = self.algo(grid_vm, grid_vm[start], grid_vm[goal]) self.grid_view.set_vm(grid_vm) # Update the Grid def loop(self): if self.run: self.step() self.parent.after(self.speed, self.loop) def step(self): try: (f, g, h, parent, curr) = self.search.next() curr.visited = True if self.jump is True: try: while 1: (f, g, h, parent, curr) = self.search.next() curr.visited = True self.step_num = self.step_num + 1 except StopIteration: self.run = False for s in g: self.grid_view.drawTile(s) self.g = g self.h = h # TODO Change fringe to binary heap show nodes that are in the fringe if self.path: for s in self.path: s.in_path = False self.grid_view.drawTile(s) self.path = gen_path(parent, curr) self.step_num = self.step_num + 1 self.stepCounter.configure(text="Count: " + str(self.step_num)) for s in self.path: s.in_path = True self.grid_view.drawTile(s) except StopIteration: self.run = False print("End of search") def centerWindow(self): # TODO: Modify this to instead show second window to specific position grid = self.grid_view.grid_vm tile_size = self.grid_view.tile_size (x, y) = grid.shape w = x * tile_size + 50 h = y * tile_size + 150 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w) / 2 y = (sh - h) / 2 self.parent.geometry('%dx%d+%d+%d' % (min(sw, w), min(sh, h), x, y))