def __init__(self, parent,inhandler): Text.__init__(self, parent) self.parent = parent self.inh = inhandler self.initUI()
def __init__(self, parent, filename): "Configure tags and feed file to parser." uwide = idleConf.GetOption('main', 'EditorWindow', 'width', type='int') uhigh = idleConf.GetOption('main', 'EditorWindow', 'height', type='int') uhigh = 3 * uhigh // 4 # lines average 4/3 of editor line height Text.__init__(self, parent, wrap='word', highlightthickness=0, padx=5, borderwidth=0, width=uwide, height=uhigh) normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier']) self['font'] = (normalfont, 12) self.tag_configure('em', font=(normalfont, 12, 'italic')) self.tag_configure('h1', font=(normalfont, 20, 'bold')) self.tag_configure('h2', font=(normalfont, 18, 'bold')) self.tag_configure('h3', font=(normalfont, 15, 'bold')) self.tag_configure('pre', font=(fixedfont, 12), background='#f6f6ff') self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief='solid', background='#eeffcc') self.tag_configure('l1', lmargin1=25, lmargin2=25) self.tag_configure('l2', lmargin1=50, lmargin2=50) self.tag_configure('l3', lmargin1=75, lmargin2=75) self.tag_configure('l4', lmargin1=100, lmargin2=100) self.parser = HelpParser(self) with open(filename, encoding='utf-8') as f: contents = f.read() self.parser.feed(contents) self['state'] = 'disabled'
def __init__(self, master=None, change_hook=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) self.change_hook = change_hook self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM,fill=X) kw.update({'yscrollcommand': self.vbar.set}) kw.update({'xscrollcommand': self.hbar.set}) kw.update({'wrap': 'none'}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview self.hbar['command'] = self.xview # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = list(vars(Text).keys()) methods = list(vars(Pack).keys()) + list(vars(Grid).keys()) + list(vars(Place).keys()) methods = set(methods).difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, parent, filename): "Configure tags and feed file to parser." Text.__init__(self, parent, wrap='word', highlightthickness=0, padx=5, borderwidth=0) normalfont = self.findfont(['TkDefaultFont', 'arial', 'helvetica']) fixedfont = self.findfont(['TkFixedFont', 'monaco', 'courier']) self['font'] = (normalfont, 12) self.tag_configure('em', font=(normalfont, 12, 'italic')) self.tag_configure('h1', font=(normalfont, 20, 'bold')) self.tag_configure('h2', font=(normalfont, 18, 'bold')) self.tag_configure('h3', font=(normalfont, 15, 'bold')) self.tag_configure('pre', font=(fixedfont, 12)) self.tag_configure('preblock', font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief='solid', background='#eeffcc') self.tag_configure('l1', lmargin1=25, lmargin2=25) self.tag_configure('l2', lmargin1=50, lmargin2=50) self.tag_configure('l3', lmargin1=75, lmargin2=75) self.tag_configure('l4', lmargin1=100, lmargin2=100) self.parser = HelpParser(self) with open(filename, encoding='utf-8') as f: contents = f.read() self.parser.feed(contents) self['state'] = 'disabled'
def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) #>>>MNC: For horizontal scrollbar try: self.hbar = None if kw['wrap'] == NONE: self.hbar = Scrollbar(self.frame, orient=HORIZONTAL) self.hbar.pack(side=BOTTOM, fill=X) kw.update({'xscrollcommand': self.hbar.set}) except KeyError: self.hbar = None #<<<MNC kw.update({'yscrollcommand': self.vbar.set}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview #>>>MNC: For horizontal scrollbar if self.hbar is not None: self.hbar['command'] = self.xview #<<<MNC # Copy geometry methods of self.frame without overriding Text # methods -- hack! text_meths = vars(Text).keys() methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys() methods = methods.difference(text_meths) for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, parent, filename): "Configure tags and feed file to parser." uwide = idleConf.GetOption("main", "EditorWindow", "width", type="int") uhigh = idleConf.GetOption("main", "EditorWindow", "height", type="int") uhigh = 3 * uhigh // 4 # lines average 4/3 of editor line height Text.__init__(self, parent, wrap="word", highlightthickness=0, padx=5, borderwidth=0, width=uwide, height=uhigh) normalfont = self.findfont(["TkDefaultFont", "arial", "helvetica"]) fixedfont = self.findfont(["TkFixedFont", "monaco", "courier"]) self["font"] = (normalfont, 12) self.tag_configure("em", font=(normalfont, 12, "italic")) self.tag_configure("h1", font=(normalfont, 20, "bold")) self.tag_configure("h2", font=(normalfont, 18, "bold")) self.tag_configure("h3", font=(normalfont, 15, "bold")) self.tag_configure("pre", font=(fixedfont, 12), background="#f6f6ff") self.tag_configure( "preblock", font=(fixedfont, 10), lmargin1=25, borderwidth=1, relief="solid", background="#eeffcc" ) self.tag_configure("l1", lmargin1=25, lmargin2=25) self.tag_configure("l2", lmargin1=50, lmargin2=50) self.tag_configure("l3", lmargin1=75, lmargin2=75) self.tag_configure("l4", lmargin1=100, lmargin2=100) self.parser = HelpParser(self) with open(filename, encoding="utf-8") as f: contents = f.read() self.parser.feed(contents) self["state"] = "disabled"
def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y) kw.update({'yscrollcommand': self.vbar.set}) Text.__init__(self, self.frame, **kw) self.pack(side=LEFT, fill=BOTH, expand=True) self.vbar['command'] = self.yview # Copy geometry methods of self.frame -- hack! methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys() for m in methods: if m[0] != '_' and m != 'config' and m != 'configure': setattr(self, m, getattr(self.frame, m))
def __init__(self, parent, spell=None, **kw): Text.__init__(self, parent, wrap="word", font="Times 14", takefocus=True, **kw) self.tg_regexp = re.compile("<[^>]*>") self.bind("<Control-c>", self.copy) self.bind("<Control-x>", self.cut) self.bind("<Return>", self.newline) self.tag_configure("h1", font="Times 16 bold", relief="raised") self.tag_configure("highlight", background="yellow", relief="raised") self.tag_configure("html_tag", foreground="blue") if spell: r, self.wd = pipe() self.rd, w = pipe() args = spell.split() self.sp = Popen(args, stdin=r, stdout=w) self.tag_configure("misspelled", foreground="red", underline=True) self.bind("<space>", self.Spellcheck) self.percolator = Percolator(self) self.percolator.insertfilter(HtmlColorDelegator())
def __init__(self, widget: tk.Text, level=logging.NOTSET): self.widget = widget super().__init__(level) # Assign colours for each logging level for level, colour in LVL_COLOURS.items(): widget.tag_config( logging.getLevelName(level), foreground=colour, # For multi-line messages, indent this much. lmargin2=30, ) widget.tag_config( logging.getLevelName(logging.CRITICAL), background='red', ) # If multi-line messages contain carriage returns, lmargin2 doesn't # work. Add an additional tag for that. widget.tag_config( 'INDENT', lmargin1=30, lmargin2=30, ) widget['state'] = "disabled"
font='time 15 bold roman ', fg='red') P_L.pack() P_L = Label(root, text=" PRGLTH -->" + str(ProgLen1), font='time 15 bold roman ', fg='red') P_L.pack() P_N = Label(root, text="PRGNAME -->" + ProgName, font='time 15 bold roman', fg='red') P_N.pack() TI = Label(root, text=" SYBTAB ", font='time 15 bold roman ', fg='black') TI.pack() ST = Text(root, font='time 15 bold roman', height=100, width=100) ST.configure(background="white") ST.insert(END, symboltab) ST.pack() literals = Label(root, text=" Literal :", font='time 15 bold roman') literals.pack() literals1 = Text(root, height=100, width=100, font='time 15 roman') literals1.insert(END, Literal_Table) literals1.pack() root.mainloop()
command=lambda: btn6u()).grid(row=55, column=1) btn7 = tkinter.Button( window, text="Move!", fg="black", command=lambda: bt7(entry4.get(), entry4.delete(0, 'end'))) btn0.bind("<Button-1>", webapp.bt0) btn0.grid(row=2, column=1) btn1.bind("<Button-1>", webapp.bt1) btn1.grid(row=20, column=1) btn5.grid(row=0, column=2) btn2.grid(row=30, column=1) btn7.grid(row=40, column=2) txt = Text(window, width=25, height=2) txt.grid(row=20, column=2, columnspan=2) scrollb = Scrollbar(window, command=txt.yview) txt['yscrollcommand'] = scrollb.set combo = ttk.Combobox(window) combo['values'] = (5, 6, 7, 8, 9, 10) combo.current(5) combo.grid(column=1, row=60) tkinter.Label(window, text="Stockfish Level").grid(row=60, column=2) combo2 = ttk.Combobox(window) combo2['values'] = (1, 2, 3, 5, 10, 15, 20) combo2.current(3) combo2.grid(column=1, row=70) tkinter.Label(window, text="Depth").grid(row=70, column=2) combo3 = ttk.Combobox(window)
# create a entry box where user can enter a keyword keyword_entry = Entry(top_frame, font=("Arial", 20, "bold"), width=25, bd=4) keyword_entry.pack(side="left", ipady=6) # create a search button search_button = Button(top_frame, text="Get Summary", font=("Arial", 16, "bold"), width=15, bd=4, command=get_summary) search_button.pack(side="right") # create a scroll bar for text area scroll = Scrollbar(bottom_frame) # create a text area where summary will be displayed answer = Text(bottom_frame, font=("Arial", 18), fg="black", width=55, height=20, bd=5, yscrollcommand=scroll.set) answer.pack(side="left", fill="y") scroll.pack(side="left", fill="y") # start the GUI root.mainloop()
#Method to exit from the root window. def exit(): result = messagebox.askyesno('exit', 'Are you sure want to exit') if result == True: sys.exit() else: pass #Label for printing -->>To-Do List<<-- on root wimdow. label = Label(root, text="To-Do List", width="9", font='10') label.place(x=42, y=25) #Entry for input as here user will enter the task to add in task_list(ListBox). entry = Text(root, width=30, height="1") # entry.insert("end",'Enter your task') # entry.bind("<Button>",Add_Task) entry.place(x=42, y=55) #ListBox for keeping the all tasks. mylist = Listbox(root, width=50, height=20) mylist.place(x=42, y=100) #Button for adding new tasks in task_list(ListBox). add_item_button = Button(root, text="Add to-do item", command=add_task, width=15) add_item_button.place(x=435, y=170)
def __init__(self, master): self.master = master master.title("MTHE 493 Presentation GUI") master.geometry("1250x1000") self.label = Label(master, text="Two Way Text Data Communication", font=("Helvetica", 16)) self.label.place(x=450, y = 20) self.close_button = Button(master, text="Close", command=master.quit) self.close_button.place(x= 625, y = 550) v1 = "" self.text1 = Text(master, height = 20, width = 40 ) self.text1.place(x=65,y=90) v2 = "" self.text2 = Text(master, height=20, width=40) self.text2.place(x=465, y=90) v3 = "" self.text3 = Text(master, height=20, width=40) self.text3.place(x=865, y=90) #v4 = "" #self.text4 = Text(master, height=20, width=20) #self.text4.place(x=1000, y=90) def find_value(letter1, letter2, transition): for subletter in transition[letter1]: if list(subletter.keys())[0] == letter2: return list(subletter.values())[0] return 0 # Channel error for letter1 and letter2 def errormatrix(letter1, letter2): if letter1 == letter2: return 1 - error else: return (error) / 25 # Find letter that corresponds to maximum probability value of dict within dict def max_letter(dictstruct, letter): maxkey = '' maxvalue = 0 for element in dictstruct.keys(): if dictstruct[element][letter] > maxvalue: maxvalue = dictstruct[element][letter] maxkey = element else: continue return maxkey # Find letter that corresponds to maximum probability value of dict def single_max_letter(dictstruct): maxkey = '' maxvalue = 0 for element in dictstruct.keys(): if dictstruct[element] > maxvalue: maxvalue = dictstruct[element] maxkey = element else: continue return maxkey def toWord(word): inputmessage = word encoded_message = [] distorted_message = [] unicoded_distorted_message = [] error = .05 # Create enough dictionaries for length of input message for x in range(1, len(inputmessage) + 1): globals()['dict%s' % x] = {} # ----------------- Add Noise to message Start ----------- for char in inputmessage: encoded_message.append(ord(char) - 97) for char in encoded_message: a = random.uniform(0, 1) if 25 >= char >= 0 and a > 1 - error: distorted_message.append((char + random.randrange(1, 25, 1)) % 26) else: distorted_message.append(char) #print(encoded_message) #print(distorted_message) for char in distorted_message: unicoded_distorted_message.append(chr((char + 97))) #unicoded_distorted_message[0] = inputmessage[0] #unicoded_distorted_message[len(inputmessage) - 1] = inputmessage[len(inputmessage) - 1] outputmessage = "" for element in unicoded_distorted_message: outputmessage = outputmessage + element return outputmessage def verturbi(transition, singledist, outputmessage, alphabet): for letter in alphabet: dict1[letter] = singledist[letter] * errormatrix(letter, outputmessage[0]) #print(dict1) for letter in alphabet: for letter2 in alphabet: if letter not in dict2.keys(): dict2[letter] = {letter2: dict1[letter] * find_value(letter, letter2, transition) * errormatrix(letter2,outputmessage[1])} else: dict2[letter][letter2] = dict1[letter] * find_value(letter, letter2, transition) * errormatrix(letter2, outputmessage[1]) #print(dict2) for i in range(3, len(outputmessage)+1): try: j = i - 1 for letter in alphabet: for letter2 in alphabet: if letter not in globals()['dict%s' % i].keys(): globals()['dict%s' % i][letter] = {letter2: globals()['dict%s' % j][max_letter(globals()['dict%s' % j], letter)][letter] * find_value(letter, letter2, transition) * errormatrix(letter2,outputmessage[j])} else: globals()['dict%s' % i][letter][letter2] = globals()['dict%s' % j][max_letter(globals()['dict%s' % j], letter)][letter] * find_value(letter, letter2, transition) * errormatrix(letter2, outputmessage[j]) print(str(i)) print(globals()['dict%s' % i]) except: continue # Find best path across nodes def set_imessage(): print(self.text1.get("1.0","end-1c")) inputmessage = str(self.text1.get("1.0","end-1c")) self.text2.delete('1.0', "end-1c") self.text3.delete('1.0', "end-1c") outputm = "" for element in inputmessage.split(' '): if len(element) > 0: outputm = outputm + " " + toWord(str(element).lower()) self.text2.insert("end-1c", outputm) decodedmessage = "" for element in outputm.split(' '): print(outputm.split(' ')) if len(element) > 1 and element.isalpha(): print(element) verturbi(transition, singledist, element, alphabet) nodes = {} i = len(element) for letter in alphabet: globals()['dict%s' % i][max_letter(globals()['dict%s' % i], letter)][letter] nodes[letter] = globals()['dict%s' % i][max_letter(globals()['dict%s' % i], letter)][letter] print(nodes) # Assign corresponding characters to maxletter(i) globals()['maxletter%s' % i] = single_max_letter(nodes) for i in range(len(element), 1, -1): j = i - 1 globals()['maxletter%s' % j] = max_letter(globals()['dict%s' % i], globals()['maxletter%s' % i]) # Put together word word = "" for i in range(1, len(element) + 1): word = word + globals()['maxletter%s' % i] print(word) decodedmessage = decodedmessage + " " + word else: decodedmessage = decodedmessage + " " + element self.text3.insert("end-1c", decodedmessage) self.button1 = Button(master, text="Veturbi", command=set_imessage) self.button1.place(x=625, y=450)
def min_char(): min_info = sbk.lowest_character_length_with_names() min_info_box = Text(window, width=26, height=2) min_info_box.grid(row=9, column=2) min_info_box.insert("end", min_info)
def insert(self, index, text, *args): line = int(self.index(index).split(".")[0]) Text.insert(self, index, text, *args) for i in range(text.count("\n")): self.colorize(str(line+i))
def retrieve_content(self, text_widget: tk.Text): content = text_widget.get("1.0", tk.END) return str(content)
language = Menu(menubar, tearoff=0) option = Menu(menubar, tearoff=0) menubar.add_cascade(label='Language', menu=language) menubar.add_cascade(label='Option', menu=option) for label, value in lang: language.add_radiobutton(label=label, variable=lang_choice, value=value) option.add_command(label='Exit', command=root.quit) frame = Frame(root) scrollbar = Scrollbar(frame, orient=VERTICAL) text = Text(frame, state='disable', font=( '宋体', 12, ), yscrollcommand=scrollbar.set) scrollbar.pack(side=RIGHT, fill=Y) scrollbar.config(command=text.yview) text.pack() frame.pack(expand=True, fill='both') root.config(menu=menubar) thread = Thread(target=translate) thread.daemon = True thread.start() root.mainloop()
def __init__(self, parent): self.set_global_var() self.window = parent parent.title("Hive Test Automation - API Response") parent.configure(background='#F4FFFF') self.position_window(parent, w=920, h=500) Frame.__init__(self, parent) #Style - Background color s = ttk.Style() #s.configure('.', background='black') ttk.Style().configure("TButton", padding=6, relief="flat", bg='#000000', fg='#b7f731', background="pale green") #Frame self.mainframe = ttk.Frame(self, padding="50 10 30 255") self.mainframe.configure(style='TFrame') self.mainframe.grid(column=0, row=0, sticky=(N)) self.mainframe.columnconfigure(0, weight=1) self.mainframe.rowconfigure(0, weight=1) #Frame self.resposeFrame = ttk.Frame(self, padding="10 10 10 10") self.resposeFrame.configure(style='TFrame') self.resposeFrame.grid(column=1, row=0, sticky=(N, W, E, S)) self.resposeFrame.columnconfigure(0, weight=1) self.resposeFrame.rowconfigure(0, weight=1) #Variables self.Environment = StringVar() self.APIValidation = StringVar() self.UserName = StringVar() self.Password = StringVar() self.Response = StringVar() self.EndPoint = StringVar() self.Node = StringVar() self.appHighlightFont = font.Font(family='Helvetica', size=22, weight='bold') ttk.Label(self.mainframe, text='Get', font=self.appHighlightFont).grid(column=3, row=0, sticky=E) ttk.Label(self.mainframe, text='API Response', font=self.appHighlightFont).grid(column=15, row=0, sticky=W) #Environment ttk.Label(self.mainframe, text='Environment: ').grid(column=3, row=1, sticky=E) self.oEnvironment = ttk.Combobox(self.mainframe, textvariable=self.Environment) self.oEnvironment['values'] = ('isopInternProd', 'isopBeta', 'isopStaging', 'isopProd') self.oEnvironment.state(['readonly']) self.oEnvironment.set('isopInternProd') self.oEnvironment.grid(column=15, row=1, sticky=W) ''' #API Validation ttk.Label(self.mainframe, text='API Validation: ').grid(column=3, row=2, sticky=E) self.oAPIValidation = ttk.Combobox(self.mainframe, textvariable=self.APIValidation) self.oAPIValidation['values'] = ('Platform API') self.oAPIValidation.state(['readonly']) self.oAPIValidation.set('Platform API') self.oAPIValidation.grid(column=15, row=2, sticky=W) ''' #User Name self.lblUserName = ttk.Label(self.mainframe, text='User Name: ') self.lblUserName.grid(column=3, row=3, sticky=E) self.oUserName = ttk.Combobox(self.mainframe, textvariable=self.UserName) self.oUserName['values'] = ('auto1_v6', 'tester2', 'tester4_v6') self.oUserName.set(utils.getAttribute('common', 'userName')) self.oUserName.grid(column=15, row=3, sticky=W) #Password self.lblPassword = ttk.Label(self.mainframe, text='Password: '******'values'] = ('password1', 'Password1', 'passw0rd') self.oPassword.set(utils.getAttribute('common', 'password')) self.oPassword.grid(column=15, row=4, sticky=W) self.boolUserPassDestroyed = False #End Point self.lblEPType, self.EPType = self.create_combobox( 5, ' End Point: ', self.EndPoint, (), "", False) self.EPType['values'] = ('Heating', 'Hot Water', 'Common') self.EPType.bind('<<ComboboxSelected>>', self.update_available_nodes) self.EPType.state(['readonly']) self.EPType.set('Heating') #Nodes self.lblNode, self.oNode = self.create_combobox( 6, 'Node: ', self.Node, (), "", False) self.oNode['values'] = ('Mode', 'Schedule', 'Running State') self.oNode.state(['readonly']) self.oNode.set('Mode') self.update_available_nodes(None) #Respose and Load Scroll bars xscrollbar = Scrollbar(self.resposeFrame, orient=HORIZONTAL) xscrollbar.grid(row=2, column=17, sticky=E + W) yscrollbar = Scrollbar(self.resposeFrame) yscrollbar.grid(row=2, column=17, sticky=N + S) self.Response = Text(self.resposeFrame, width=70, height=30, wrap=NONE, bd=0, xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set) self.Response.pack() self.Response.grid(column=17, row=2, sticky=W) xscrollbar.config(command=self.Response.xview) yscrollbar.config(command=self.Response.yview) #Exucute & Quit Buttons ttk.Label(self.mainframe, text='').grid(column=3, row=14, sticky=E) ttk.Label(self.mainframe, text='').grid(column=15, row=14, sticky=E) oExecute = ttk.Button(self.mainframe, text='Execute', command=self.load_response) oExecute.grid(column=15, row=15, sticky=W) oExecute = ttk.Button(self.mainframe, text='Quit', command=self.closeWidget) oExecute.grid(column=15, row=15, sticky=E)
def initUI(self): self.parent.title("") #self.style = Style() #self.style.theme_use("clam") #self.pack(fill=BOTH, expand = 1) self.quitbutton = Button(self, text="Quit", command=lambda: self.quit()) self.quitbutton.grid(row=3, column=1, pady=4) self.labelErrorPointer = Label(self, text="◀") self.labellist = [] self.entrylist = [] self.verifylist = [] self.misclist = [] self.optionCreate = "Create" self.optionUpcoming = "Upcoming" self.optionPast = "Past" self.prevmode = self.optionCreate self.curmode = self.optionCreate self.optionvar = tkinter.StringVar(self) self.optionvar.trace("w", self.permaloop) self.optionvar.set(self.optionCreate) self.option = OptionMenu(self, self.optionvar, self.optionCreate, self.optionUpcoming, self.optionPast) self.optionpostmodevar = tkinter.StringVar(self) self.optionpostmodevar.trace("w", self.permaloop) self.optionpostmodevar.set('url') self.optionpostmode = OptionMenu(self, self.optionpostmodevar, 'url', 'text') self.labelText = Label(self, text='Selftext:') self.entryText = Text(self) self.labelURL = Label(self, text='URL:') self.entryURL = Entry(self) self.entryURL.configure(width=60) self.sql = sqlite3.connect('sql.db') print('Loaded SQL Database') self.cur = self.sql.cursor() self.cur.execute( 'CREATE TABLE IF NOT EXISTS upcoming(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT)' ) self.cur.execute( 'CREATE TABLE IF NOT EXISTS past(ID TEXT, SUBREDDIT TEXT, TIME INT, TITLE TEXT, URL TEXT, BODY TEXT, POSTLINK TEXT)' ) self.cur.execute( 'CREATE TABLE IF NOT EXISTS internal(NAME TEXT, ID INT)') print('Loaded Completed table') self.cur.execute('SELECT * FROM internal') f = self.cur.fetchone() if not f: print('Database is new. Adding ID counter') self.cur.execute('INSERT INTO internal VALUES(?, ?)', ['counter', 1]) self.idcounter = 1 else: self.idcounter = f[1] print('Current ID counter: ' + str(self.idcounter)) self.sql.commit() sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() w = 853 h = 480 x = (sw - w) / 2 y = (sh - h) / 2 self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y - 50)) self.login()
def __init__(self, photoDescription, photo, filename): """Constructor.""" self.root = Tk() # "%dx%d%+d%+d" % (width, height, xoffset, yoffset) self.root.geometry("%ix%i+10-10" % (config.tkhorsize, config.tkvertsize)) self.root.title(filename) self.photoDescription = photoDescription self.filename = filename self.photo = photo self.skip = False self.exit = False # --Init of the widgets # The image self.image = self.getImage(self.photo, 800, 600) self.imagePanel = Label(self.root, image=self.image) self.imagePanel.image = self.image # The filename self.filenameLabel = Label(self.root, text=u"Suggested filename") self.filenameField = Entry(self.root, width=100) self.filenameField.insert(END, filename) # The description self.descriptionLabel = Label(self.root, text=u"Suggested description") self.descriptionScrollbar = Scrollbar(self.root, orient=VERTICAL) self.descriptionField = Text(self.root) self.descriptionField.insert(END, photoDescription) self.descriptionField.config( state=NORMAL, height=12, width=100, padx=0, pady=0, wrap=WORD, yscrollcommand=self.descriptionScrollbar.set) self.descriptionScrollbar.config(command=self.descriptionField.yview) # The buttons self.okButton = Button(self.root, text="OK", command=self.okFile) self.skipButton = Button(self.root, text="Skip", command=self.skipFile) # --Start grid # The image self.imagePanel.grid(row=0, column=0, rowspan=11, columnspan=4) # The buttons self.okButton.grid(row=11, column=1, rowspan=2) self.skipButton.grid(row=11, column=2, rowspan=2) # The filename self.filenameLabel.grid(row=13, column=0) self.filenameField.grid(row=13, column=1, columnspan=3) # The description self.descriptionLabel.grid(row=14, column=0) self.descriptionField.grid(row=14, column=1, columnspan=3) self.descriptionScrollbar.grid(row=14, column=5)
def __init__(self, parent, scrollbar, list_model_factory): Text.__init__(self, parent, yscrollcommand=scrollbar.set) self._list_model_factory = list_model_factory self._list_model = list_model_factory.get_list_model() self._list_model.add_listener(self._list_items_changed)
from tkinter import Tk from tkinter import Text texto = """ AAAAAAAA aaaaaaaa llllllll LLLLLLLL QQQQQQQQ WWWWWWWW (((()))) ******** mostrene if 1==1: """ tela = Tk() fonte = 'fonte/Roboto_Mono/RobotoMono-Regular.ttf' resource.add_font(fonte) action_man = font.load('Roboto Mono') tx = Text(tela, font=("Ubuntu Mono", 15)) tx.insert(1.0, texto) tx.grid() tela.mainloop()
def __init__(self, *args, **kwargs): Frame.__init__(self, *args, **kwargs); self.toForeGround ################### init, main config ###################### container = Frame(self, bg=bgColor); container.pack(side="top", fill="both", expand=True); self.ft1 = font.Font(family='Arial', size=11); self.ft2 = font.Font(family='MS Gothic', size=10); self.ft3 = font.Font(family='Arial', size=9); self.ft4 = font.Font(family='Arial', size=10); self.ft5 = font.Font(family='Arial', size=14); self.ft6 = font.Font(family="Courier", size = 9); self.p1 = Page1(container, bg=container["background"]); self.p2 = Page2(container, bg=container["background"]); self.p3 = Page3(container, bg=container["background"]); self.p4 = Page4(container, bg=container["background"]); self.p5 = Page5(container, bg=container["background"]); self.p6 = Page6(container, bg=container["background"]); self.p7 = Page7(container, bg=container["background"]); self.p8 = Page8(container, bg=container["background"]); self.p9 = Page9(container, bg=container["background"]); topBar = Frame(container, bg=topBarColor, width=container.winfo_width() * framewidth, height=topBarHeight); topBar.place(x=0, y=0); self.p1.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p2.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p3.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p4.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p5.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p6.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p7.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p8.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); self.p9.place(in_=container, x=0, y= topBar["height"], relwidth=1, relheight=1); close= Button(topBar, text=u"\u2715", command= lambda: self.close(), bg=topBar["background"], bd=0, font = self.ft2, fg=fgColor, activebackground="#940000"); close.place(x = topBar["width"] - topBar["height"], y = 0, width = topBar["height"], height= topBar["height"]); minim = Button(topBar, text="_", command= lambda: self.toicon(), bg=topBar["background"], bd=0, font=self.ft2, fg=fgColor, activebackground="#364969"); minim.place(x = topBar["width"] - 2 * topBar["height"], y = 0, width = topBar["height"], height= topBar["height"]); label = Label(topBar, text=title, font=self.ft3, bg=topBar["background"], fg=fgColor); label.place(x = 5, y = 0, height= topBar["height"]); #event handlers so the window can be moved topBar.bind("<ButtonPress-1>", self.StartMove); topBar.bind("<ButtonRelease-1>", self.StopMove); topBar.bind("<B1-Motion>", self.OnMotion); label.bind("<ButtonPress-1>", self.StartMove); label.bind("<ButtonRelease-1>", self.StopMove); label.bind("<B1-Motion>", self.OnMotion); close.bind("<Enter>", self.closeEnterBG); close.bind("<Leave>", self.topBarButtonNormalBG); minim.bind("<Enter>", self.minimEnterBG); minim.bind("<Leave>", self.topBarButtonNormalBG); self.master.bind("<Unmap>", self.toiconify); self.master.bind("<Map>", self.todeiconify); ##################### page 1, intro ############################ T1 = Text(self.p1, height = 8, width = 31, font=self.ft5, bg=bgColor, fg=fgColor, bd=0); T1.place(x=10, y=10); HelpButton = Label(self.p1, text = "help", background=bgColor, fg = hyperlinkColor, font = self.ft5, cursor="hand2"); HelpButton.place(x=8, y=53); underlineFont = font.Font(HelpButton, HelpButton.cget("font")); underlineFont.configure(underline = True); HelpButton.configure(font=underlineFont); HelpButton.bind("<Button-1>", lambda x: self.clickHelp()) T2 = Text(self.p1, height = 8, width = 31, font=self.ft5, bg=bgColor, fg=fgColor, bd=0); T2.place(x=53, y=55); T1.insert(END, "Welcome to the ELS Scorion tool. Click next to select what tool to use, or press\n"); T2.insert(END, "to learn more about the tool."); T1.configure(state=DISABLED); T2.configure(state=DISABLED); nextButtonP1 = Button(self.p1, text = "Next", command=self.p2.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); nextButtonP1.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); nextButtonP1.bind("<Enter>", self.buttonEnterBG); nextButtonP1.bind("<Leave>", self.buttonNormalBG); ################## page 2, task picker ######################### instrLabel = Label(self.p2, text = "Choose what tool to use", bg=self.p2["background"], fg=fgColor, font=self.ft5); instrLabel.place(x= 30, y = 10); buildGroupsButton = Button(self.p2, text = "Build Scorion groups", command=self.p3.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft5, activebackground=buttonPressedColor, activeforeground=fgColor); buildGroupsButton.place(x = 75, y = 48, width = 250, height = 2*nextprevButtonHeight); buildGroupsButton.bind("<Enter>", self.buttonEnterBG); buildGroupsButton.bind("<Leave>", self.buttonNormalBG); splitGroupsButton = Button(self.p2, text = "Split Scorion file", command=self.p4.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft5, activebackground=buttonPressedColor, activeforeground=fgColor); splitGroupsButton.place(x = 75, y = 120, width = 250, height = 2*nextprevButtonHeight); splitGroupsButton.bind("<Enter>", self.buttonEnterBG); splitGroupsButton.bind("<Leave>", self.buttonNormalBG); onlyFileButton = Button(self.p2, text = "Only create Scorion file", command=self.p5.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft5, activebackground=buttonPressedColor, activeforeground=fgColor); onlyFileButton.place(x = 75, y = 192, width = 250, height = 2*nextprevButtonHeight); onlyFileButton.bind("<Enter>", self.buttonEnterBG); onlyFileButton.bind("<Leave>", self.buttonNormalBG); possibleErrorButton = Button(self.p2, text = "Find errors in file", command=self.p8.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft5, activebackground=buttonPressedColor, activeforeground=fgColor); possibleErrorButton.place(x = 75, y = 264, width = 250, height = 2*nextprevButtonHeight); possibleErrorButton.bind("<Enter>", self.buttonEnterBG); possibleErrorButton.bind("<Leave>", self.buttonNormalBG); previousButtonP2 = Button(self.p2, text = "Back", command=self.p1.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP2.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP2.bind("<Enter>", self.buttonEnterBG); previousButtonP2.bind("<Leave>", self.buttonNormalBG); ################## page 3, group builder ######################## previousButtonP3 = Button(self.p3, text = "Back", command=self.p2.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP3.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP3.bind("<Enter>", self.buttonEnterBG); previousButtonP3.bind("<Leave>", self.buttonNormalBG); courseIdWrap = Frame(self.p3, bg= self.p3["background"]); courseIdWrap.place(x = 10, y = 10, width = framewidth - 20, height = topBarHeight) self.courseVar = StringVar(); self.courseVar.trace("w", lambda name, index, mode, courseVar=self.courseVar: self.firecallback()); courseIdLabel = Label(courseIdWrap, text = "Course Id:", bg=self.p3["background"], fg=fgColor, font=self.ft4); courseIdLabel.place(x= 0, y = 0, height = topBarHeight); courseId = Entry(courseIdWrap, width= 45, bg=bg2Color, textvariable=self.courseVar,fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); courseId.place(x = 65, y = 0, height=topBarHeight); fileWrap = Frame(self.p3, bg =self.p3["background"]); fileWrap.place(x = 10, y = 44, width = framewidth - 20, height = topBarHeight); fileLabel = Label(fileWrap, text = "File:", bg=self.p3["background"], fg=fgColor, font=self.ft4); fileLabel.place(x= 30, y = 0, height = topBarHeight); self.fileVar = StringVar(); self.fileVar.trace("w", lambda name, index, mode, fileVar=self.fileVar: self.firecallback()); self.fileName = Entry(fileWrap, width= 36, textvariable=self.fileVar,bg=bg2Color, fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); self.fileName.place(x = 65, y = 0, height= topBarHeight); #TODO: drag files into the text field self.browse = Button(fileWrap, text="Browse", command=self.load_file, background=buttonColor, foreground=fgColor, bd=0, font=self.ft4, activebackground=buttonPressedColor, activeforeground=fgColor, anchor="center"); self.browse.place(x=326, y=0, height = topBarHeight, width=60); self.browse.bind("<Enter>", self.buttonEnterBG); self.browse.bind("<Leave>", self.buttonNormalBG); seperatorWrap = Frame(self.p3, bg = self.p3["background"]); seperatorWrap.place(x=10, y = 106, height = 2*topBarHeight + 2, width = framewidth - 20); optionLabel = Label(seperatorWrap, text="What seperator is used in the file?", bg=self.p3["background"], fg=fgColor, font=self.ft4); optionLabel.place(x = 0, y = 0, height = topBarHeight); optionList = [("Comma ( , )", ","),("Semicolon ( ; )", ";")]; self.sepVar = StringVar(); self.sepVar.set(optionList[0][1]); commaButton = Radiobutton(seperatorWrap, text=optionList[0][0], variable = self.sepVar, value=optionList[0][1], anchor="w", padx=5, bg=bg2Color, fg=fgColor, activebackground=bg2Color, activeforeground=fgColor, selectcolor=bg2Color); semiColonButton = Radiobutton(seperatorWrap, text=optionList[1][0], variable = self.sepVar, value=optionList[1][1], anchor="w", padx=5, bg=bg2Color, fg=fgColor, activebackground=bg2Color, activeforeground=fgColor, selectcolor=bg2Color); commaButton.place(x=260, y=0, height=topBarHeight, width = 120); semiColonButton.place(x=260, y = topBarHeight + 2, width = 120); optionLabel = Label(self.p3, text="Do you already have a Scorion File?"); scorionCheckWrap = Frame(self.p3, bg = self.p3["background"]); scorionCheckWrap.place(x=10, y = 194, height=topBarHeight, width = framewidth - 20); self.checkVar = IntVar(); scorionCheck = Checkbutton(scorionCheckWrap, text="Create a Scorion file?", var = self.checkVar, font=self.ft4, fg=fgColor, bg=bg2Color, bd=0, highlightthickness = 0, selectcolor=bg2Color, activeforeground=fgColor, activebackground= bg2Color); scorionCheck.select(); scorionCheck.place(x=210, y=0, height=topBarHeight, width = 170); self.goButton = Button(self.p3, text = "Run", command=self.combineFuncs, state=DISABLED,background=disabledButtonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=disabledButtonColor, activeforeground=fgColor, disabledforeground=fg2Color); self.goButton.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); ################### page 4, split groups page ######################## previousButtonP4 = Button(self.p4, text = "Back", command=self.p2.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP4.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP4.bind("<Enter>", self.buttonEnterBG); previousButtonP4.bind("<Leave>", self.buttonNormalBG); scorFileWrap = Frame(self.p4, bg =self.p4["background"]); scorFileWrap.place(x = 10, y = 10, width = framewidth - 20, height = topBarHeight); fileLabel = Label(scorFileWrap, text = "Scorion File:", bg=self.p4["background"], fg=fgColor, font=self.ft4); fileLabel.place(x= 0, y = 0, height = topBarHeight); self.scorFileVar = StringVar(); self.scorFileVar.trace("w", lambda name, index, mode, scorFileVar=self.scorFileVar: self.firecallback1()); self.scorFileName = Entry(scorFileWrap, width= 34, textvariable=self.scorFileVar,bg=bg2Color, fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); self.scorFileName.place(x = 79, y = 0, height= topBarHeight); self.browse1 = Button(scorFileWrap, text="Browse", command=self.load_file1, background=buttonColor, foreground=fgColor, bd=0, font=self.ft4, activebackground=buttonPressedColor, activeforeground=fgColor, anchor="center"); self.browse1.place(x=326, y=0, height = topBarHeight, width=60); self.browse1.bind("<Enter>", self.buttonEnterBG); self.browse1.bind("<Leave>", self.buttonNormalBG); errFileWrap = Frame(self.p4, bg =self.p4["background"]); errFileWrap.place(x = 10, y = 44, width = framewidth - 20, height = topBarHeight); errLabel = Label(errFileWrap, text = "Error File:", bg=self.p4["background"], fg=fgColor, font=self.ft4); errLabel.place(x= 0, y = 0, height = topBarHeight); self.errFileVar = StringVar(); self.errFileVar.trace("w", lambda name, index, mode, errFileVar=self.errFileVar: self.firecallback1()); self.errFileName = Entry(errFileWrap, width= 36, textvariable=self.errFileVar,bg=bg2Color, fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); self.errFileName.place(x = 65, y = 0, height= topBarHeight); self.browse2 = Button(errFileWrap, text="Browse", command=self.load_file2, background=buttonColor, foreground=fgColor, bd=0, font=self.ft4, activebackground=buttonPressedColor, activeforeground=fgColor, anchor="center"); self.browse2.place(x=326, y=0, height = topBarHeight, width=60); self.browse2.bind("<Enter>", self.buttonEnterBG); self.browse2.bind("<Leave>", self.buttonNormalBG); self.goButtonP4 = Button(self.p4, text = "Run", command=self.combineFuncs2, state=DISABLED,background=disabledButtonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=disabledButtonColor, activeforeground=fgColor, disabledforeground=fg2Color); self.goButtonP4.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); ################### page 5, only create groups page ################## previousButtonP5 = Button(self.p5, text = "Back", command=self.p2.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP5.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP5.bind("<Enter>", self.buttonEnterBG); previousButtonP5.bind("<Leave>", self.buttonNormalBG); courseIdWrap2 = Frame(self.p5, bg= self.p5["background"]); courseIdWrap2.place(x = 10, y = 10, width = framewidth - 20, height = topBarHeight) self.courseVar2 = StringVar(); self.courseVar2.trace("w", lambda name, index, mode, courseVar2=self.courseVar2: self.firecallback2()); courseIdLabel2 = Label(courseIdWrap2, text = "Course Id:", bg=self.p5["background"], fg=fgColor, font=self.ft4); courseIdLabel2.place(x= 0, y = 0, height = topBarHeight); courseId2 = Entry(courseIdWrap2, width= 45, bg=bg2Color, textvariable=self.courseVar2,fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); courseId2.place(x = 65, y = 0, height=topBarHeight); fileWrap2 = Frame(self.p5, bg =self.p5["background"]); fileWrap2.place(x = 10, y = 44, width = framewidth - 20, height = topBarHeight); fileLabel2 = Label(fileWrap2, text = "File:", bg=self.p5["background"], fg=fgColor, font=self.ft4); fileLabel2.place(x= 30, y = 0, height = topBarHeight); self.fileVar2 = StringVar(); self.fileVar2.trace("w", lambda name, index, mode, fileVar2=self.fileVar2: self.firecallback2()); self.fileName2 = Entry(fileWrap2, width= 36, textvariable=self.fileVar2,bg=bg2Color, fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); self.fileName2.place(x = 65, y = 0, height= topBarHeight); self.browse3 = Button(fileWrap2, text="Browse", command=self.load_file3, background=buttonColor, foreground=fgColor, bd=0, font=self.ft4, activebackground=buttonPressedColor, activeforeground=fgColor, anchor="center"); self.browse3.place(x=326, y=0, height = topBarHeight, width=60); self.browse3.bind("<Enter>", self.buttonEnterBG); self.browse3.bind("<Leave>", self.buttonNormalBG); seperatorWrap2 = Frame(self.p5, bg = self.p5["background"]); seperatorWrap2.place(x=10, y = 106, height = 2*topBarHeight + 2, width = framewidth - 20); optionLabel2 = Label(seperatorWrap2, text="What seperator is used in the file?", bg=self.p5["background"], fg=fgColor, font=self.ft4); optionLabel2.place(x = 0, y = 0, height = topBarHeight); optionList2 = [("Comma ( , )", ","),("Semicolon ( ; )", ";")]; self.sepVar2 = StringVar(); self.sepVar2.set(optionList2[0][1]); commaButton2 = Radiobutton(seperatorWrap2, text=optionList2[0][0], variable = self.sepVar2, value=optionList2[0][1], anchor="w", padx=5, bg=bg2Color, fg=fgColor, activebackground=bg2Color, activeforeground=fgColor, selectcolor=bg2Color); semiColonButton2 = Radiobutton(seperatorWrap2, text=optionList2[1][0], variable = self.sepVar2, value=optionList2[1][1], anchor="w", padx=5, bg=bg2Color, fg=fgColor, activebackground=bg2Color, activeforeground=fgColor, selectcolor=bg2Color); commaButton2.place(x=260, y=0, height=topBarHeight, width = 120); semiColonButton2.place(x=260, y = topBarHeight + 2, width = 120); self.goButtonP5 = Button(self.p5, text = "Run", command=self.combineFuncs3, state=DISABLED,background=disabledButtonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=disabledButtonColor, activeforeground=fgColor, disabledforeground=fg2Color); self.goButtonP5.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); ################### page 6, progress page ########################### self.cancelButton = Button(self.p6, text = "cancel", command=lambda:sys.exit(), background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); self.cancelButton.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); self.cancelButton.bind("<Enter>", self.buttonEnterBG); self.cancelButton.bind("<Leave>", self.buttonNormalBG); self.progressLabel = Label(self.p6, text = "Working, this might take a couple of minutes...", bg=self.p6["background"], fg=fgColor, font=self.ft1) self.progressLabel.place(x=10, y=36); #TODO: make the progressbar actually progress to the things that are done style = Style(); style.theme_use('alt') style.configure("els.Horizontal.TProgressbar", background=fgColor); self.progress = Progressbar(self.p6, orient=HORIZONTAL, length = framewidth - 20, mode="indeterminate", style="els.Horizontal.TProgressbar", maximum=40); self.progress.place(x=10, y=10); self.progress.start(17); self.closeP6 = Button(self.p6, text = "Close", command=self.close, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); ################### page 7, error page ########################### #TODO: implement full stacktrace instead of only 2 #TODO: or: make a log file of the stacktrace that can be "downloaded" when clicked #TODO: error page is not working correctly anymore; errors are being cut off self.errorLabel = Label(self.p7, text = "Something went wrong, try again or contact Cas", bg=self.p7["background"], fg=errorColor, font=self.ft1); self.errorLabel.place(x=36, y=10); self.errorInfoLabel = Label(self.p7, text = "Error Info:", bg=self.p7["background"], fg=fgColor, font=self.ft1); self.errorInfoLabel.place(x=36, y=50); self.stackTraceStringVar1 = StringVar(); self.stackTraceStringVar2 = StringVar(); self.stackTraceLabel1 = Label(self.p7, textvariable = self.stackTraceStringVar1, bg=self.p7["background"], fg=errorColor, font=self.ft1, wraplength = 350, justify=LEFT); self.stackTraceLabel2 = Label(self.p7, textvariable = self.stackTraceStringVar2, bg=self.p7["background"], fg=errorColor, font=self.ft1, wraplength = 350, justify=LEFT); self.stackTraceStringVar1.set(self.getStackTrace()[0]); self.stackTraceStringVar2.set(self.getStackTrace()[1]); self.stackTraceLabel1.place(x=36, y=70); self.stackTraceLabel2.place(x=36, y=110); self.backToMenu = Button(self.p7, text = "Back to menu", command=self.backtomenu, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); self.backToMenu.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); self.backToMenu.bind("<Enter>", self.buttonEnterBG); self.backToMenu.bind("<Leave>", self.buttonNormalBG); self.closeP7 = Button(self.p7, text = "Close", command=self.close, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); self.closeP7.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); self.closeP7.bind("<Enter>", self.buttonEnterBG); self.closeP7.bind("<Leave>", self.buttonNormalBG); ################### page 8, find error page ########################### previousButtonP8 = Button(self.p8, text = "Back", command=self.p2.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP8.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP8.bind("<Enter>", self.buttonEnterBG); previousButtonP8.bind("<Leave>", self.buttonNormalBG); checkErrFileWrap = Frame(self.p8, bg =self.p8["background"]); checkErrFileWrap.place(x = 10, y = 10, width = framewidth - 20, height = 3*topBarHeight); checkErrLabel = Label(checkErrFileWrap, text = "File to check for Errors:", bg=self.p4["background"], fg=fgColor, font=self.ft4); checkErrLabel.place(x= 0, y = 0, height = topBarHeight); self.checkErrFileVar = StringVar(); self.checkErrFileVar.trace("w", lambda name, index, mode, checkErrFileVar=self.checkErrFileVar: self.firecallback3()); self.checkErrFileName = Entry(checkErrFileWrap, width= 45, textvariable=self.checkErrFileVar,bg=bg2Color, fg=fgColor, borderwidth = 0, font=self.ft4, insertbackground=fgColor, insertofftime= 500, insertontime= 500); self.checkErrFileName.place(x = 2, y = 25, height= topBarHeight); self.browse4 = Button(checkErrFileWrap, text="Browse", command=self.load_file4, background=buttonColor, foreground=fgColor, bd=0, font=self.ft4, activebackground=buttonPressedColor, activeforeground=fgColor, anchor="center"); self.browse4.place(x=326, y=25, height = topBarHeight, width=60); self.browse4.bind("<Enter>", self.buttonEnterBG); self.browse4.bind("<Leave>", self.buttonNormalBG); self.goButtonP8 = Button(self.p8, text = "Run", command=self.p9.lift, state=DISABLED,background=disabledButtonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=disabledButtonColor, activeforeground=fgColor, disabledforeground=fg2Color); self.goButtonP8.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); ################### page 9, find error results ########################### previousButtonP9 = Button(self.p9, text = "Back", command=self.p8.lift, background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); previousButtonP9.place(x = nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); previousButtonP9.bind("<Enter>", self.buttonEnterBG); previousButtonP9.bind("<Leave>", self.buttonNormalBG); #testing self.checkErrFileName.delete(0, END); self.checkErrFileName.insert(0, r"M:\ud\os\ssc\imos\bbsup\@ new folder_Surfdrive\7. Scorion\Vakmappen 171804\46597-171804\group_import_no_TAs.txt"); self.errors = errorChecker(self.checkErrFileVar.get()); self.croppedErrors = self.errors[0:7] if (len(self.errors) > 0): Label(self.p9, text = "Found %d possible errors, on the following lines:" %len(self.errors), fg = fgColor, bg = bgColor, font = self.ft1).place(x=16, y=12); openFile = Button(self.p9, text = "Open file", command=lambda: self.clickOpenFile(), background=buttonColor, foreground=fgColor, bd=0, font=self.ft1, activebackground=buttonPressedColor, activeforeground=fgColor); openFile.place(x = framewidth - nextprevButtonWidth - nextprevButtonPaddingX, y = frameheight - nextprevButtonHeight - nextprevButtonPaddingY, width = nextprevButtonWidth, height = nextprevButtonHeight); openFile.bind("<Enter>", self.buttonEnterBG); openFile.bind("<Leave>", self.buttonNormalBG); self.drawErrors(); else: Label(self.p9, text = "Found no errors", fg = fgColor, bg = bgColor, font = self.ft5).place(x=10, y=10); ################### finally, show page 1 to start ################ self.p1.show();
class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() def generate(self): n = int(self.menu_gen.get()) seed = self.inp_seed.get() self.output = Generator.convert(seed, n) if len(self.output) > 0: self.generated = True self.butt_draw.config( state= 'normal') self.chek_fullscrn.config(state= 'normal') self.clearOutput(self.output) def draw(self, n, step=False): p1, p2 = Draw.move(n) self.curr_canvas.create_line(p1[0], p1[1], p2[0], p2[1], fill= self.color, width= self.thick) if step: self.curr_canvas.update_idletasks() def do(self, action, step, rainbow): if len(action) > 1: p = action[1] else: p = 1.0 self.timebuff += step cmd = action[0].lower() if cmd == "draw": if rainbow: self.incColor() if self.incThickYN: self.incThick(self.reverseThick, False) elif self.incThickYN: self.incThick(self.reverseThick, True) if self.timebuff > 1.0: truncate = int(self.timebuff) self.after(truncate, self.draw(float(p), True)) self.timebuff -= truncate else: self.draw(float(p)) elif cmd == "turn": Draw.turn(float(p)) elif cmd == "skip": Draw.skip(float(p)) elif cmd == "back": Draw.back(float(p)) elif cmd == "color": if not rainbow: self.color = Color.getHexString(p) elif cmd == "thick": self.thick = int(p) else: print("Unknown command " + cmd) def drawAll(self, newWindow= True): if self.generated == True: self.butt_print.config(state= 'disabled') self.timebuff = 0.0 self.color = Color.white() self.thick = 2 l = float(self.slid_linesize.get()) a = float(self.slid_angle.get()) Draw.init(self.startingPoint, l, a) if self.fullScreen.get() == 1: if newWindow: self.curr_canvas = dc.BigCanvas(self).canvas self.canvas.delete("all") else: self.curr_canvas = self.canvas self.curr_canvas.delete("all") self.curr_canvas.config(bg= Color.getHexString(self.bgColor.get())) rainbow = self.rainbowCheck.get() == 1 if rainbow or self.incThickYN: self.incStep = 1.0/float(self.getDrawCount(self.output)) self.percent = 0.0 for c in self.output: if c == '[': Draw.push() elif c == ']': Draw.pop() else: for r in Rule.getDrawings(): if c == r[0]: if len(r) > 2: params = (r[1], r[2]) else: params = (r[1],) s = float(self.slid_timer.get()) self.do(params, s, rainbow) break self.butt_print.config(state= 'normal') def incColor(self): self.color = Color.getValueByPercent(self.percent) self.percent += self.incStep def incThick(self, reverse, incYN): maxthick = 5 minthick = 1 diff = maxthick - minthick if reverse: result = maxthick - int(diff * self.percent) else: result = minthick + int(diff * self.percent) self.thick = result if incYN: self.percent += self.incStep def getDrawCount(self, s): draw_commands = [] for r in Rule.getDrawings(): if r[1].lower() == "draw": draw_commands.append(r[0]) draw_count = 0; for c in s: for d in draw_commands: if c == d: draw_count += 1 break return draw_count def clearOutput(self, replacement=None): self.text_output.config(state= 'normal') self.text_output.delete(1.0, END) if replacement: self.text_output.insert(END, replacement) self.text_output.config(state= 'disabled') def formatRules(self, rules): ret = [] for r in rules: entry = r[0] + " | " + r[1] if len(r) > 2: entry += " " + r[2] ret.append(entry) return ret def getRuleFromFormatted(self, s): if s: rule = s.split('|') rule[0] = rule[0].strip() rule[1] = rule[1].strip() prod = rule[1].split(" ") if len(prod) == 1: return (rule[0], prod[0]) else: return (rule[0], prod[0], prod[1]) def RefreshLists(self): self.list_prod.delete(0, END) self.list_draw.delete(0, END) l = self.formatRules(Rule.getProductions()) for p in l: self.list_prod.insert(END, p) l = self.formatRules(Rule.getDrawings()) for d in l: self.list_draw.insert(END, d) def AddProductionRule(self, edit=None): rule = dp.AddProductionRuleDialog(self, edit).result if rule: if edit: Rule.removeProd(edit[0]) Rule.AddProduction(rule) self.RefreshLists() def AddDrawingRule(self, edit=None): rule = dd.AddDrawingRuleDialog(self, edit).result if rule: if edit: Rule.removeDraw(edit[0]) Rule.AddDrawing(rule) self.RefreshLists() def EditProductionRule(self): s = self.list_prod.curselection() if s: idx = s[0] rule = (idx,) + self.getRuleFromFormatted(self.list_prod.get(idx)) if rule: self.AddProductionRule(rule) def EditDrawingRule(self): s = self.list_draw.curselection() if s: idx = s[0] rule = (idx,) + self.getRuleFromFormatted(self.list_draw.get(idx)) if rule: self.AddDrawingRule(rule) def DeleteProductionRule(self): s = self.list_prod.curselection() if s: Rule.removeProd(s[0]) self.RefreshLists() def DeleteDrawingRule(self): s = self.list_draw.curselection() if s: Rule.removeDraw(s[0]) self.RefreshLists() def packOutput(self): ret = "" ret += self.packAxiom() ret += self.packProdRules() ret += self.packDrawRules() return ret def packAxiom(self): return "@" + str(self.inp_seed.get()).strip() def packRules(self, rules): ret = "@" for r in rules: ret += "$" + str(r[0]) + "|" + str(r[1]) if len(r) > 2: ret += ":" + str(r[2]) return ret def packProdRules(self): return self.packRules(Rule.getProductions()) def packDrawRules(self): return self.packRules(Rule.getDrawings()) def parseProdRules(self, raw): rules = raw.split('$') for rule in rules: if rule is not "": r = rule.split('|') Rule.AddProduction((r[0], r[1])) def parseDrawRules(self, raw): rules = raw.split('$') for rule in rules: if rule is not "": r = rule.split('|') p = r[1].split(':') if len(p) == 1: tup = (r[0], p[0]) else: tup = (r[0], p[0], p[1]) Rule.AddDrawing(tup) def parseSaveFile(self, s): Rule.wipe() settings = s.split('@') self.inp_seed.set(str(settings[1])) self.parseProdRules(settings[2]) self.parseDrawRules(settings[3]) self.RefreshLists() def save(self): try: filename = filedialog.asksaveasfilename(**self.file_options['txt']) if filename: f = open(filename, 'w') f.write(self.packOutput()) f.close() except Exception as e: print("File IO error in save\n", e) def load(self): try: filename = filedialog.askopenfilename(**self.file_options['txt']) if filename: f = open(filename, 'r') self.parseSaveFile(f.read()) f.close() self.slid_linesize.set(1.0) self.slid_timer.set(0.0) self.menu_gen.set(1) self.clearOutput() except Exception as e: print("File IO error in load\n" + e) def help(self): help.HelpDialog(self) def saveImage(self): filename = filedialog.asksaveasfilename(**self.file_options['ps']) self.curr_canvas.postscript(file=filename, colormode='color') def click(self, event): self.startingPoint = (event.x, event.y) def clickAndRedraw(self, event): self.click(event) self.drawAll(False) def fileOptions(self): self.file_options = {} txt_options = {} ps_options = {} txt_options['defaultextension'] = '.txt' txt_options['filetypes'] = [('Plaintext', '.txt')] txt_options['initialdir'] = 'Patterns' ps_options['defaultextension'] = '.ps' ps_options['filetypes'] = [('Postscript Image', '.ps')] ps_options['initialdir'] = 'Images' self.file_options['txt'] = txt_options self.file_options['ps'] = ps_options def makeMenuBar(self): self.menubar = Menu(self); self.menubar.add_command(label="Save", command= self.save) self.menubar.add_command(label="Load", command= self.load) self.menubar.add_command(label="Help", command= self.help) root.config(menu= self.menubar) def makeInputFrame(self): self.inp_seed = String() self.bgColor = String() self.gen_value = Int() self.rainbowCheck = Int() self.fram_input = Frame(self, bd= 2, relief= self.style, width= input_frame_width, height= input_frame_height) self.fram_seed = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_prod = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_draw = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_drawParams = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_gen = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_output = Frame(self.fram_input, bd= 1, relief= self.style) self.menu_gen = DropDown(self.fram_gen, textvariable= self.gen_value, state= 'readonly') self.entr_seed = Input(self.fram_seed, textvariable= self.inp_seed) self.text_output = Output(self.fram_output, width= 35, height= 10) self.scrl_output = Scrollbar(self.fram_output) self.list_prod = List(self.fram_prod, selectmode= BROWSE, font= "Courier 8", height= 5) self.list_draw = List(self.fram_draw, selectmode= BROWSE, font= "Courier 8", height= 5) self.slid_linesize = Slider(self.fram_drawParams, from_= 0.1, to= 10.0, orient= HORIZONTAL, resolution= 0.1, length= 180) self.slid_timer = Slider(self.fram_drawParams, from_= 0, to= 2, orient= HORIZONTAL, resolution= 0.02, length= 180) self.slid_angle = Slider(self.fram_drawParams, from_= 0, to= 359, orient= HORIZONTAL, length= 180) self.entr_bgcolor = Input (self.fram_drawParams, textvariable= self.bgColor) self.butt_prodAdd = Button(self.fram_prod, text= "Add", width=8, command= self.AddProductionRule) self.butt_prodEdit = Button(self.fram_prod, text= "Edit", width=8, command= self.EditProductionRule) self.butt_prodDelete = Button(self.fram_prod, text= "Delete", width=8, command= self.DeleteProductionRule) self.butt_drawAdd = Button(self.fram_draw, text= "Add", width=8, command= self.AddDrawingRule) self.butt_drawEdit = Button(self.fram_draw, text= "Edit", width=8, command= self.EditDrawingRule) self.butt_drawDelete = Button(self.fram_draw, text= "Delete", width=8, command= self.DeleteDrawingRule) self.chek_incColor = CheckBox(self.fram_draw, text= "Rainbow", variable= self.rainbowCheck) Label(self.fram_seed, text= "Axiom:", width=8).grid (row=0, column=0) Label(self.fram_prod, text= "Production\nRules:", width=8).grid (row=0, column=0) Label(self.fram_draw, text= "Drawing\nRules:", width=8).grid (row=0, column=0) Label(self.fram_drawParams, text= "Line Size:").grid (row=0, column=0) Label(self.fram_drawParams, text= "Delay (ms):").grid (row=1, column=0) Label(self.fram_drawParams, text= "Starting Angle:").grid (row=2, column=0) Label(self.fram_drawParams, text= "Background Color:").grid (row=3, column=0) Label(self.fram_output, text= "Output:").grid (row=0, column=0) Label(self.fram_gen, text= "Generations:").grid (row=0, column=0) self.gen_value.set(1) self.menu_gen['values'] = tuple(range(1, 13)) self.slid_linesize.set(1.0) self.bgColor.set( Color.default() ) self.text_output.config(state='disabled', yscrollcommand= self.scrl_output.set) self.scrl_output.config(command=self.text_output.yview) self.fram_input.grid (row=0, column=0) self.fram_seed.grid (row=1, column=0, sticky= 'ew') self.fram_prod.grid (row=2, column=0, sticky= 'ew') self.fram_draw.grid (row=3, column=0, sticky= 'ew') self.fram_drawParams.grid (row=4, column=0, sticky= 'ew') self.fram_gen.grid (row=5, column=0, sticky= 'ew') self.fram_output.grid (row=6, column=0, sticky= 'ew') self.entr_seed.grid (row=0, column=1, sticky= 'ew') self.list_prod.grid (row=0, column=1, sticky= 'ew') self.butt_prodAdd.grid (row=1, column=0, sticky= 'ew') self.butt_prodEdit.grid (row=1, column=1, sticky= 'ew') self.butt_prodDelete.grid (row=1, column=2, sticky= 'ew') self.list_draw.grid (row=0, column=1) self.butt_drawAdd.grid (row=1, column=0, sticky= 'ew') self.butt_drawEdit.grid (row=1, column=1, sticky= 'ew') self.butt_drawDelete.grid (row=1, column=2, sticky= 'ew') self.chek_incColor.grid (row=0, column=2) self.slid_linesize.grid (row=0, column=1, sticky= 'ew') self.slid_timer.grid (row=1, column=1, sticky= 'ew') self.slid_angle.grid (row=2, column=1, sticky= 'ew') self.entr_bgcolor.grid (row=3, column=1, sticky= 'ew') self.menu_gen.grid (row=0, column=1, sticky= 'ew') self.text_output.grid (row=1, column=0) self.scrl_output.grid (row=1, column=1, sticky= 'ns') def makeCanvasFrame(self): self.fram_canvas = Frame(self, bd=10, relief=self.style) self.canvas = Canvas(self.fram_canvas, width= canvas_width, height= canvas_height) self.fram_canvas.grid(row=0, column=1, sticky='nesw') self.canvas.grid(sticky='nesw') self.canvas.bind("<Button-1>", self.click) self.curr_canvas = self.canvas def makeIgnitionFrame(self): self.fullScreen = Int() self.fram_ignition = Frame(self, bd=4, relief=self.style, width= ignition_frame_width, height= ignition_frame_height) self.butt_generate = Button(self.fram_ignition, text= " -- GENERATE -- ", width=111, command= self.generate) self.butt_draw = Button(self.fram_ignition, text= " -- DRAW -- ", width=100, command= self.drawAll, state= 'disabled') self.butt_print = Button(self.fram_ignition, text= "Save Image", command= self.saveImage, state= 'disabled') self.chek_fullscrn = CheckBox(self.fram_ignition, text= "Fullscreen", variable= self.fullScreen, state= 'disabled') self.fram_ignition.grid(row=1, column=0, columnspan=2) self.butt_generate.grid(row=0, column=0, columnspan=2) self.butt_draw.grid( row=1, column=0) self.butt_print.grid( row=0, column=2, rowspan= 2, sticky='ns') self.chek_fullscrn.grid(row=1, column=1) def createWidgets(self): self.incThickYN = False self.reverseThick = False self.style = RIDGE self.startingPoint = (20, 20) self.generated = False self.fileOptions() self.makeMenuBar() self.makeInputFrame() self.makeCanvasFrame() self.makeIgnitionFrame()
def setUpClass(cls): cls.root = Tk() cls.text = Text(cls.root)
def disable(self, disable): Text.config(self, state=DISABLED if disable else NORMAL)
window.lblsellorders.place(relx=0.14, rely=0.01, relheight=0.03, relwidth=0.12) window.lstsellorders = Listbox(window.mainframe) window.lstsellorders.bind("<<ListboxSelect>>", sellorderselect) window.lstsellorders.place(relx=0.14, rely=0.04, relheight=0.45, relwidth=0.12) # Buy Orders window.lblbuyorders = Label(window.mainframe, text="Buy Orders") window.lblbuyorders.place(relx=0.14, rely=0.49, relheight=0.03, relwidth=0.12) window.lstbuyorders = Listbox(window.mainframe) window.lstbuyorders.bind("<<ListboxSelect>>", buyorderselect) window.lstbuyorders.place(relx=0.14, rely=0.53, relheight=0.45, relwidth=0.12) # Market History window.lblmarkethistory = Label(window.mainframe, text="Market History") window.lblmarkethistory.place(relx=0.26, rely=0.47, relheight=0.03, relwidth=0.74) window.lstmarkethistory = Listbox(window.mainframe) window.lstmarkethistory.bind("<<ListboxSelect>>", markethistoryselect) window.lstmarkethistory.place(relx=0.26, rely=0.50, relheight=0.48, relwidth=0.74) # A Debug frame with a textbox. seems legit. window.debugframe = LabelFrame(window, text="Debug") window.debugframe.place(relx=0.01, rely=0.85, relheight=0.15, relwidth=0.99) window.txtdebug = Text(window.debugframe) window.txtdebug.place(relx=0.01, rely=0.01, relheight=0.96, relwidth=0.98) # Start the gui loop but run a function before quitting. window.protocol("WM_DELETE_WINDOW", on_closing) window.mainloop()
def chk_status(): infor = sbk.check_present(name_entry.get()) status_info = Text(window, width=16, height=2) status_info.grid(row=5, column=3) status_info.insert("end", infor)
root.bind('<Control-Key-f>', fon) root.bind('<Control-Alt-Key-t>', color) root.bind('<Control-Alt-Key-b>', color2) root.bind('<Control-Alt-Key-f>', fand) root.bind('<Control-Key-d>', done) root.bind('<Key>', Set) sb = Scrollbar(root) sb.pack(side="right", fill="y") sb2 = Scrollbar(root, orient="horizontal") sb2.pack(side="bottom", fill="x") from tkinter import font import _tkinter f = font.Font(root) #文本框 text = Text(root, undo=True, width=200, height=400, yscrollcommand=sb.set, font=f, xscrollcommand=sb2.set, wrap="none") text.pack(side="left", fill="both") sb.config(command=text.yview) sb2.config(command=text.xview) root.config(menu=mainmenu) root.mainloop()
def init_ui(self): """ setup the GUI for the app """ self.master.title("Test") self.pack(fill=BOTH, expand=True) # Input section input_frame = LabelFrame(self, text="Input") input_frame.bind("-", self.on_minus_key) input_frame.bind("+", self.on_plus_key) input_frame.pack(fill=X) self.play_button = Button(input_frame, text="Play", command=self.on_play_button_click) self.play_button.pack(side=RIGHT, padx=4) self.rec_button = Button(input_frame, text="Rec", command=self.on_rec_button_click) self.rec_button.pack(side=RIGHT, padx=4) self.wav_filename_entry = Entry(input_frame, width=24) self.wav_filename_entry.pack(fill=X) self.wav_filename_entry.delete(0, END) if self.wav_filename: self.wav_filename_entry.insert(0, self.wav_filename) # Feature section features_frame = LabelFrame(self, text="Features") features_frame.pack(fill=X) features_control_frame = Frame(features_frame) features_control_frame.pack(fill=X) load_features_button = Button(features_control_frame, text="Load", command=self.on_load_featurizer_model) load_features_button.pack(side=RIGHT) self.features_entry = Entry(features_control_frame, width=8) self.features_entry.pack(fill=X) self.features_entry.delete(0, END) if self.featurizer_model: self.features_entry.insert(0, self.featurizer_model) viz_frame = Frame(features_frame) viz_frame.pack(fill=X) self.features_figure = Figure(figsize=(5, 4), dpi=100) self.subplot = self.features_figure.add_subplot(111) canvas = FigureCanvasTkAgg(self.features_figure, master=viz_frame) canvas.draw() canvas.show() canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True) # Classifier section classifier_frame = LabelFrame(self, text="Classifier") classifier_frame.pack(fill=X) load_classifier_button = Button(classifier_frame, text="Load", command=self.on_load_classifier) load_classifier_button.pack(side=RIGHT) self.classifier_entry = Entry(classifier_frame, width=8) self.classifier_entry.pack(fill=X) self.classifier_entry.delete(0, END) if self.classifier_model: self.classifier_entry.insert(0, self.classifier_model) # Output section output_frame = LabelFrame(self, text="Output") output_frame.pack(fill=BOTH, expand=True) self.output_text = Text(output_frame) self.output_text.pack(fill=BOTH, padx=4, expand=True)
def __init__(self, root, jsonissue, jsonlabels, jsonmilestones, jsoncontributors): ttk.Frame.__init__(self, root) irow = 0 icol = 0 # Label(root, text='Title').grid(row=0, column=0, sticky=W) # print(jsonissue["milestone"]) ''' Layout: 0 1 2 3 Title Labels | Description Milestone | Comments Status | Comments Assignees | Comments ''' entryTitle = Entry(root, width=80, font='Verdana 14 normal') # width=50, entryTitle.grid(row=irow, column=0, sticky=W + E + N + S, padx=5, pady=5) entryTitle.insert(0, jsonissue["title"]) irow += 1 Label(root, text='Labels').grid(row=irow, column=0, sticky=E + W) irow += 1 checks = {} for label in jsonlabels: # setattr(checks, label["name"], '') checks[label["name"]] = '' c = tk.Checkbutton(root, text=label["name"], variable=checks[label["name"]]) c.grid(row=irow, column=0, sticky=W) print(label) irow += 1 entryLabels = Entry(root) # width=50 entryLabels.grid(row=irow, column=0, padx=5, pady=5, sticky=E + W) entryLabels.insert(0, str(jsonissue["labels"])) irow += 1 Label(root, text='Milestone').grid(row=irow, column=0, sticky=E + W) irow += 1 entryMilestone = Entry(root, width=50) entryMilestone.grid(row=irow, column=0, padx=5, pady=5, sticky=E + W) entryMilestone.insert(0, str(jsonissue["milestone"])) irow += 1 Label(root, text='Assignees').grid(row=irow, column=0, sticky=E + W) irow += 1 entryAssignees = Entry(root, width=50) entryAssignees.grid(row=irow, column=0, padx=5, pady=5, sticky=E + W) entryAssignees.insert(0, jsonissue["assignees"]) irow += 1 Label(root, text='Status').grid(row=irow, column=0, sticky=E + W) irow += 1 entryStatus = Entry(root, width=50) entryStatus.grid(row=irow, column=0, padx=5, pady=5, sticky=E + W) entryStatus.insert(0, jsonissue["state"]) irow += 1 Label(root, text='Description').grid(row=irow, column=0, sticky=E + W) irow += 1 entryBody = Text(root, font='Verdana 10 normal') entryBody.grid(row=irow, column=0, columnspan=2, padx=5, pady=5, sticky=N + E + S + W) entryBody.insert(0.0, jsonissue["body"]) # lblResult = Label(root, text="") # lblResult.grid(row=7, column=0, columnspan=2, padx=5, pady=5) irow += 1 buttonSave = Button(root, text="Save", command=lambda: root.saveIssue( { "title": entryTitle.get(), "body": entryBody.get("1.0", END), "labels": entryLabels.get(), "milestone": entryMilestone.get(), "assignees": entryAssignees.get(), "status": entryStatus.get(), }, lblResult)) buttonSave.grid(row=irow, column=0, columnspan=4, padx=5, pady=5) irow += 1 buttonClose = Button(root, text="Close", command=root.closeButton) buttonClose.grid(row=irow, column=0, columnspan=4, padx=5, pady=5)
self.l = Label(top, text="Password Name:") self.l.pack() self.e = Entry(top) self.e.pack() self.b = Button(top, text='Ok', command=self.cleanup) self.b.pack() def cleanup(self): self.value = self.e.get() self.top.destroy() print(self.value) saved_password = open("save.txt", "a") pussy = (self.value + ": ") save_pass = (pussy + generated_password) saved_password.write("\n" + save_pass) popupWindow(window) Button(window, text="Generate", command=Generate).pack() e = Text(window, height=17, width=45) e.pack() e2 = Entry(window, width=10) e2.place(x=100) e2.insert(0, "6") Button(window, text="Save", command=save_password).pack()
search_btn = Button(toolbar, image=useImg4, command=lambda: callback("clicked search icon")) search_btn.pack(side=LEFT, fill=X) ttips.Create(search_btn, 'Search') music_btn = Button(toolbar, image=useImg5, command=lambda: callback("clicked music icon")) music_btn.pack(side=LEFT, fill=X) ttips.Create(music_btn, 'Play Music') exit_btn = Button(toolbar, image=useImg6, command=root.destroy) exit_btn.pack(side=LEFT, fill=X) ttips.Create(exit_btn, 'Exit') # Add the toolbar. toolbar.pack(side=TOP, fill=X) # Set up a Text box and scroll bar. scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) text = Text(root) text.pack() text.config(yscrollcommand=scrollbar.set) scrollbar.config(command=text.yview) root.mainloop()
def setUpClass(cls): cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) cls.editwin = DummyEditwin(cls.text) cls.editwin.text_frame = Mock()
def __init__(self, parent): Text.__init__(self, parent) self.parent = parent
def __init__(self, *args, **kwargs): Text.__init__(self, *args, **kwargs) self.redirector = WidgetRedirector(self) self.insert = self.redirector.register("insert", lambda *args, **kw: "break") self.delete = self.redirector.register("delete", lambda *args, **kw: "break")
def __init__(self, parent, file=None): Text.__init__(self, parent, wrap=NONE, undo=True, maxundo=-1, borderwidth='0p') self.vbar = Scrollbar(parent, name='vbar_tiborcim') self.xbar = Scrollbar(parent, name='xbar_tiborcim', orient="horizontal") self.bind('<Button-3>',CimEditMenu, add='') self.vbar['command'] = self.yview self.vbar.pack(side="right", fill=Y) self['yscrollcommand'] = self.vbar.set self.xbar['command'] = self.xview self.xbar.pack(side="bottom", fill=X) self['xscrollcommand'] = self.xbar.set self.pack(expand=1, fill="both") self.tag_configure("keyword", foreground="#ff0000") self.tag_configure("string", foreground="#28a030") self.tag_configure("block", foreground="#0000ff") self.tag_configure("builtin", foreground="#9228a0") self.tag_configure("comment", foreground="#74787f") def text_changed(evt): if file is not None: file.saved = False line, col = self.index('insert').split('.') txt = self.get('%s.0' % line, '%s.end' % line) blocks = [ "WHILE", "WEND", # WHILE loop "SUB", "END SUB", # SUBs "IF", "ELSEIF", "ELSE", "END IF", "THEN",# IF control "FOR", "TO", "NEXT", # FOR loop "PYTHON", "END PYTHON" # PYTHON block ] builtins = [ "INT", "RND", "SHAKEN", "NOT", "AND", "OR" # Not implemented ] builtinvars = [ "STR\$", "INKEY\$", "RECEIVE\$" ] keywords = [ "SCREEN", "PSET", # Leds "RADIO\W(ON|OFF)", "BROADCAST", # Radio communications "PRINT", "SHOW", "IMAGE", "SLEEP" ] strings = [ "\"(.*?)\"", "'(.*?)'" ] self.tag_remove('builtin', '1.0', 'end') self.tag_remove('keyword', '1.0', 'end') self.tag_remove('string', '1.0', 'end') self.tag_remove('block', '1.0', 'end') for builtin in builtins: self.highlight_pattern("\y" + builtin + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "builtin", '1.0', 'end', True) for builtinvar in builtinvars: self.highlight_pattern("\y" + builtinvar + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "builtin", '1.0', 'end', True) for keyword in keywords: self.highlight_pattern("\y" + keyword + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "keyword", '1.0', 'end', True) for string in strings: self.highlight_pattern(string + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "string", '1.0', 'end', True) for block in blocks: self.highlight_pattern("\y" + block + "\y(?=([^\"]*\"[^\"]*\")*[^\"]*$)", "block", '1.0', 'end', True) self.highlight_pattern("^\'(.*?)$", "comment", '1.0', 'end', True) self.edit_modified(False) self.bind('<<Modified>>', text_changed)
def write_text_and_disable(widget_txt: tk.Text, txt: str): widget_txt.configure(state=tk.NORMAL) widget_txt.delete('1.0', tk.END) widget_txt.insert(tk.END, txt) widget_txt.configure(state=tk.DISABLED)
def shift_cipher_page(): global key_input, plaintext_input, ciphertext_input, key_error, plaintext_error, ciphertext_error clear_screen(mainframe) # ? Title Label(mainframe, text="Shift Cipher", font=h1_font, bg=main_colour).grid(row=0, column=0, columnspan=3) # ? # ? Plaintext Frame plaintext_frame = Frame(mainframe, bg=main_colour) plaintext_frame.grid(row=1, column=0) Label(plaintext_frame, text="Plaintext:", font=h2_font, background=main_colour).grid(row=0, column=0, padx=10, pady=10) plaintext_input = Text(plaintext_frame, width=box_width, height=10, font=h3_font, relief="solid") plaintext_input.grid(row=1, column=0, padx=10, pady=10) # ? Ciphertext Frame ciphertext_frame = Frame(mainframe, bg=main_colour) ciphertext_frame.grid(row=1, column=2) Label(ciphertext_frame, text="Ciphertext:", font=h2_font, background=main_colour).grid(row=0, column=0, padx=10, pady=10) ciphertext_input = Text(ciphertext_frame, width=box_width, height=10, font=h3_font, relief="solid") ciphertext_input.grid(row=1, column=0, padx=10, pady=10) # ? Key Frame key_frame = Frame(mainframe, bg=main_colour) key_frame.grid(row=1, column=1, padx=20) Label(key_frame, text="Key:", font=h2_font, background=main_colour).grid(row=0, column=0, padx=10, pady=10) key_input = Entry(key_frame, width=3, font=h2_font, relief="solid") key_input.grid(row=0, column=1, padx=10, pady=10) # ? # ? Button Frame button_frame = Frame(mainframe, bg=main_colour) button_frame.grid(row=2, column=0, columnspan=3) Button(button_frame, text="Encrypt", font=(font_family, 12), background=button_colour, command=lambda: Shift_cipher.encryption_shift()).grid(row=0, column=0, padx=10, pady=10) Button(button_frame, text="Decrypt", font=(font_family, 12), background=button_colour, command=lambda: Shift_cipher.decryption_shift()).grid(row=0, column=1, padx=10, pady=10) # ? Error Frame error_frame = Frame(mainframe, bg=main_colour) error_frame.grid(row=3, column=0, columnspan=3) plaintext_error = Label(error_frame, text="", fg="red", font=error_font, background=main_colour) plaintext_error.grid(row=0, column=0) key_error = Label(error_frame, text="", fg="red", font=error_font, background=main_colour) key_error.grid(row=1, column=0) ciphertext_error = Label(error_frame, text="", fg="red", font=error_font, background=main_colour) ciphertext_error.grid(row=2, column=0)
def __init__(self): self.ui = Tk() self.ui.title("Pick to Light {} - Designed by SWRD Alan".format( config.version)) try: self.ui.geometry(config.sizeUI) except: self.ui.geometry(config.defaultData["sizeUI"]) config.sizeUI = config.defaultData["sizeUI"] self.ui.protocol("WM_DELETE_WINDOW", self.closing) self.tab_control = ttk.Notebook(self.ui) self.home = Frame(self.tab_control) self.home.configure(background=config.backGround) self.settings = Frame(self.tab_control) self.settings.configure(background=config.backGround) self.tab_control.add(self.home, text="Home") self.tab_control.add(self.settings, text="Settings") self.tab_control.pack(expand=1, fill='both') self.ui.update() self.sizeFont = min(self.ui.winfo_height(), self.ui.winfo_width()) / 23 # initialization Home tablel self.status = StringVar() self.LineNameH = StringVar() self.RackNameH = StringVar() self.ModelNameH = StringVar() self.KeyPartNoH = StringVar() self.NextModelH = StringVar() self.NextKeyPartH = StringVar() self.RackRun = StringVar() self.ModelRun = StringVar() self.KeyPartRun = StringVar() self.SlotRun = StringVar() self.Labelstatus = Label(self.home, textvariable=self.status, bg="green" , fg="white", \ font=("Courier", round(self.sizeFont / 1.5), "bold")) #initialization Setting table self.IPServerTextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.PortServerTextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=6, height=1) self.CMC1Textbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.CMC2Textbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.BaudRateTextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.RackNameTextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=10, height=1) self.DoubelCheckBox = BooleanVar() self.DoubleRackCheckbox = Checkbutton(self.settings, text="Double Rack", variable=self.DoubelCheckBox, bg=config.backGround) self.GPIOSlot1 = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=3, height=1) self.GPIOSlot2 = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=3, height=1) self.GPIOSlot3 = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=3, height=1) self.GPIOSlot4 = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=3, height=1) self.ResolutionGUITextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.BackGroundTextbox = Text(self.settings, font=("Courier", round(self.sizeFont / 2)), width=15, height=1) self.setStatus() self.initHomeTab() self.initSettingsTab()
def setUpClass(cls): requires('gui') cls.root = Tk() cls.root.withdraw() cls.text = Text(cls.root) cls.acw = acw.AutoCompleteWindow(cls.text)
def makeInputFrame(self): self.inp_seed = String() self.bgColor = String() self.gen_value = Int() self.rainbowCheck = Int() self.fram_input = Frame(self, bd= 2, relief= self.style, width= input_frame_width, height= input_frame_height) self.fram_seed = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_prod = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_draw = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_drawParams = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_gen = Frame(self.fram_input, bd= 1, relief= self.style) self.fram_output = Frame(self.fram_input, bd= 1, relief= self.style) self.menu_gen = DropDown(self.fram_gen, textvariable= self.gen_value, state= 'readonly') self.entr_seed = Input(self.fram_seed, textvariable= self.inp_seed) self.text_output = Output(self.fram_output, width= 35, height= 10) self.scrl_output = Scrollbar(self.fram_output) self.list_prod = List(self.fram_prod, selectmode= BROWSE, font= "Courier 8", height= 5) self.list_draw = List(self.fram_draw, selectmode= BROWSE, font= "Courier 8", height= 5) self.slid_linesize = Slider(self.fram_drawParams, from_= 0.1, to= 10.0, orient= HORIZONTAL, resolution= 0.1, length= 180) self.slid_timer = Slider(self.fram_drawParams, from_= 0, to= 2, orient= HORIZONTAL, resolution= 0.02, length= 180) self.slid_angle = Slider(self.fram_drawParams, from_= 0, to= 359, orient= HORIZONTAL, length= 180) self.entr_bgcolor = Input (self.fram_drawParams, textvariable= self.bgColor) self.butt_prodAdd = Button(self.fram_prod, text= "Add", width=8, command= self.AddProductionRule) self.butt_prodEdit = Button(self.fram_prod, text= "Edit", width=8, command= self.EditProductionRule) self.butt_prodDelete = Button(self.fram_prod, text= "Delete", width=8, command= self.DeleteProductionRule) self.butt_drawAdd = Button(self.fram_draw, text= "Add", width=8, command= self.AddDrawingRule) self.butt_drawEdit = Button(self.fram_draw, text= "Edit", width=8, command= self.EditDrawingRule) self.butt_drawDelete = Button(self.fram_draw, text= "Delete", width=8, command= self.DeleteDrawingRule) self.chek_incColor = CheckBox(self.fram_draw, text= "Rainbow", variable= self.rainbowCheck) Label(self.fram_seed, text= "Axiom:", width=8).grid (row=0, column=0) Label(self.fram_prod, text= "Production\nRules:", width=8).grid (row=0, column=0) Label(self.fram_draw, text= "Drawing\nRules:", width=8).grid (row=0, column=0) Label(self.fram_drawParams, text= "Line Size:").grid (row=0, column=0) Label(self.fram_drawParams, text= "Delay (ms):").grid (row=1, column=0) Label(self.fram_drawParams, text= "Starting Angle:").grid (row=2, column=0) Label(self.fram_drawParams, text= "Background Color:").grid (row=3, column=0) Label(self.fram_output, text= "Output:").grid (row=0, column=0) Label(self.fram_gen, text= "Generations:").grid (row=0, column=0) self.gen_value.set(1) self.menu_gen['values'] = tuple(range(1, 13)) self.slid_linesize.set(1.0) self.bgColor.set( Color.default() ) self.text_output.config(state='disabled', yscrollcommand= self.scrl_output.set) self.scrl_output.config(command=self.text_output.yview) self.fram_input.grid (row=0, column=0) self.fram_seed.grid (row=1, column=0, sticky= 'ew') self.fram_prod.grid (row=2, column=0, sticky= 'ew') self.fram_draw.grid (row=3, column=0, sticky= 'ew') self.fram_drawParams.grid (row=4, column=0, sticky= 'ew') self.fram_gen.grid (row=5, column=0, sticky= 'ew') self.fram_output.grid (row=6, column=0, sticky= 'ew') self.entr_seed.grid (row=0, column=1, sticky= 'ew') self.list_prod.grid (row=0, column=1, sticky= 'ew') self.butt_prodAdd.grid (row=1, column=0, sticky= 'ew') self.butt_prodEdit.grid (row=1, column=1, sticky= 'ew') self.butt_prodDelete.grid (row=1, column=2, sticky= 'ew') self.list_draw.grid (row=0, column=1) self.butt_drawAdd.grid (row=1, column=0, sticky= 'ew') self.butt_drawEdit.grid (row=1, column=1, sticky= 'ew') self.butt_drawDelete.grid (row=1, column=2, sticky= 'ew') self.chek_incColor.grid (row=0, column=2) self.slid_linesize.grid (row=0, column=1, sticky= 'ew') self.slid_timer.grid (row=1, column=1, sticky= 'ew') self.slid_angle.grid (row=2, column=1, sticky= 'ew') self.entr_bgcolor.grid (row=3, column=1, sticky= 'ew') self.menu_gen.grid (row=0, column=1, sticky= 'ew') self.text_output.grid (row=1, column=0) self.scrl_output.grid (row=1, column=1, sticky= 'ns')
def know_mode(): mode_info = sbk.calc_mode() mode_box = Text(window, width=27, height=2) mode_box.grid(row=7, column=2) mode_box.insert("end", mode_info)
def init_ui(self): """ setup the GUI for the app """ self.master.title("Test") self.pack(fill=BOTH, expand=True) # Input section input_frame = LabelFrame(self, text="Input") input_frame.bind("-", self.on_minus_key) input_frame.bind("+", self.on_plus_key) input_frame.pack(fill=X) self.play_button = Button(input_frame, text="Play", command=self.on_play_button_click) self.play_button.pack(side=RIGHT, padx=4) self.rgb_canvas = tk.Canvas(input_frame, width=20, height=20, bd=0) self.rgb_oval = self.rgb_canvas.create_oval(2, 2, 20, 20, fill='#FF0000', width=0) self.rgb_canvas.pack(side=RIGHT, padx=4) self.rec_button = Button(input_frame, text="Rec", command=self.on_rec_button_click) self.rec_button.pack(side=RIGHT, padx=4) self.wav_filename_entry = Entry(input_frame, width=24) self.wav_filename_entry.pack(fill=X) self.wav_filename_entry.delete(0, END) if self.wav_filename: self.wav_filename_entry.insert(0, self.wav_filename) # Feature section features_frame = LabelFrame(self, text="Features") features_frame.pack(fill=X) features_control_frame = Frame(features_frame) features_control_frame.pack(fill=X) load_features_button = Button(features_control_frame, text="Load", command=self.on_load_featurizer_model) load_features_button.pack(side=RIGHT) self.features_entry = Entry(features_control_frame, width=8) self.features_entry.pack(fill=X) self.features_entry.delete(0, END) if self.featurizer_model: self.features_entry.insert(0, self.featurizer_model) self.spectrogram_widget = SpectrogramImage(features_frame) self.spectrogram_widget.pack(fill=X) # Classifier section classifier_frame = LabelFrame(self, text="Classifier") classifier_frame.pack(fill=X) load_classifier_button = Button(classifier_frame, text="Load", command=self.on_load_classifier) load_classifier_button.pack(side=RIGHT) self.classifier_entry = Entry(classifier_frame, width=8) self.classifier_entry.pack(fill=X) self.classifier_entry.delete(0, END) if self.classifier_model: self.classifier_entry.insert(0, self.classifier_model) # Output section output_frame = LabelFrame(self, text="Output") output_frame.pack(fill=BOTH, expand=True) self.output_text = Text(output_frame) self.output_text.pack(fill=BOTH, padx=4, expand=True)
def __init__(self, *args, **kwargs): Text.__init__(self, *args, **kwargs)
window.title(f"Simple Tkinter Text Editor - {filepath}") window = Tk() window.title("Simple Tkinter Text Editor") # Following keeps button columns to stay # fixed whilst the text box can move freely # Sets height of 1st row to 800 pixels window.rowconfigure(0, minsize=800, weight=1) # Sets height of 2nd row to 800 pixels window.columnconfigure(1, minsize=800, weight=1) # Creates area to edit text using Text widget text_edit = Text(window) frame_buttons = Frame(window) frame_buttons = Frame(window, relief=RAISED, bd=2) # Creates 2 buttons to open and save files button_open = Button(frame_buttons, text="Open", command=open_file) button_save = Button(frame_buttons, text="Save As", command=save_file) # Places open and save buttons using grid format # sticky="ew" allows buttons to expand in width button_open.grid(row=0, column=0, sticky="ew", padx=5, pady=5) button_save.grid(row=1, column=0, sticky="ew", padx=5) # Allows frame to expand vertically i.e. buttons # fill entire column