from tkinter import * from tkinter.font import Font root = Tk() root.title('Codemy.com - Custom Fonts') root.iconbitmap('c:/gui/codemy.ico') root.geometry("500x500") # Define Our Font bigFont = Font(family="Times", size=40, weight="bold", slant="roman", underline=0, overstrike=0) # Define Out Font mediumFont = Font(family="Helvetica", size=24, weight="normal", slant="italic", underline=1, overstrike=0) # Define A Button my_button1 = Button(root, text="Big Text", font=bigFont) my_button1.pack(pady=20) # Label my_label = Label(root, text="more big text", font=mediumFont) my_label.pack(pady=20)
from tkinter import * from tkinter.font import Font from tkinter import ttk window03 = Tk() window03.title("Spin Bar...") window03.geometry('300x200') spin = Spinbox(window03, from_=0, to=100, width=5, font=Font(family='Helvetica', size=36, weight='bold')) spin.pack() window03.mainloop()
import SintacticoRMT import Reportes import os from LexicoJS import * from LexicoCSS import * from LexicoHTML import * from LexicoRMT import * from SintacticoRMT import * from Reportes import * raiz = Tk() raiz.title("Compiladores 1") raiz.resizable(0, 0) raiz.geometry("1000x900") raiz.config(bg="blue4") myFont = Font(family="Arial", size=18, weight="bold") myFont2 = Font(family="Arial", size=12) myframes = [] mytexts = [] myscrolls = [] s = ttk.Style() s.configure('TNotebook.Tab', font=myFont2) archivo = "" lenguaje = "" def GenerarSalida(Tokens, path): global archivo name = os.path.basename(archivo) path += name f = open(path, "w+")
def __init__(self): global root, overviewbtn, casesbtn, curedbtn, deathbtn, otherbtn, overviews, cureds, casess, deaths, otherss, style, app #initialize font self.btnfont = Font(size=20, family='Bahnschrift Condensed') style = ttk.Style() def fixed_map(option): return [ elm for elm in style.map("Treeview", query_opt=option) if elm[:2] != ("!disabled", "!selected") ] style.map("Treeview", foreground=fixed_map("foreground"), background=fixed_map("background")) style.configure("Vertical.TScrollbar", gripcount=0, background="#191919") #initialize widget self.title = Label(root, text='COVID-19 DATA ANALYSIS', font=Font(size=30, family='Bahnschrift Condensed'), bg='#191919', fg='white') self.line = Label(bg='#555555') self.btnfrm = [Frame(root, bg='#555555') for i in range(5)] overviewbtn = Button(root, text='OVERVIEW', font=self.btnfont, relief=FLAT, fg='white', bg='#191919', activebackground='#696969', activeforeground='white', borderwidth=0) casesbtn = Button(root, text='CASES', font=self.btnfont, relief=FLAT, fg='white', bg='#191919', activebackground='#696969', activeforeground='white', borderwidth=0) curedbtn = Button(root, text='CURED', font=self.btnfont, relief=FLAT, fg='white', bg='#191919', activebackground='#696969', activeforeground='white', borderwidth=0) deathbtn = Button(root, text='DEATH', font=self.btnfont, relief=FLAT, fg='white', bg='#191919', activebackground='#696969', activeforeground='white', borderwidth=0) otherbtn = Button(root, text='OTHERS', font=self.btnfont, relief=FLAT, fg='white', bg='#191919', activebackground='#696969', activeforeground='white', borderwidth=0) #call the function and dump them into a variable respectively self.overview = overview() self.cases = cases() self.cured = cured() self.death = death() self.others = others() #call the overviews variable once when start the app #dump the variable into button command respectively overviewbtn.config(command=self.overview.widget) casesbtn.config(command=self.cases.widget) curedbtn.config(command=self.cured.widget) deathbtn.config(command=self.death.widget) otherbtn.config(command=self.others.widget)
def main(): global input_area global menu_var, results_display, entry_1, entry_2, entry_3 global entry_4, input_area, results_label ################################### # SET UP ALL THE DISPLAY COMPONENTS: ################################### # nice font: my_font = Font(family="Verdana", size=15, weight="bold") ################################### # 1. TEXT AREA THAT DISPLAYS RESULTS, USING THE ABOVE FONT ################################### results_display = tkinter.Text( root, #display needs the tkinter window to be put in height=30, relief="ridge", bd=6, width=60, font=my_font, foreground='green', background='black') photo = tkinter.PhotoImage( file='tenor.gif') # fun photo to display at start #(PhotoImages must be .gif) results_display.configure(state="normal") # allow editing of text results_display.image_create(tkinter.END, image=photo) # inserts fun photo results_display.insert(tkinter.END, " " +\ " " +\ " " +\ " " +\ " " +\ "Welcome to the stock analysis software. " +\ "This software will help you make informed market" +\ " decisions, and predict future stock price. " +\ "To save user data, use the quit button when exiting " +\ "and not the x button on the top right corner. " "Enjoy!") # insesrts default text results_display.configure(state="disabled") ################################### # 2. TEXT AREA FOR ENTERING LARGE AMOUNTS OF TEXT ################################### input_area = tkinter.Text(root, height=30, bd=2, width=60, font=my_font, foreground='red', background='black') # im = Image.open('Stock_Graph.png') Keep this for future edits(for adding stock graph) # # im = im.convert('RGB').convert('P', palette = Image.ADAPTIVE) # im.save('sg.gif') # photo2 = tkinter.PhotoImage(file='sg.gif') # fun photo to display at start # # input_area.image_create(tkinter.END, image=photo2) # inserts fun photo ################################### # 3. TEXT LABEL THAT CAN SHOW RESULTS: ################################### results_label = tkinter.Label(text="Version 1.0.0") ################################### # 4. BUTTONS ################################### # will call the submit() function when pressed: submit_button = tkinter.Button(text="SUBMIT", command=submit) # will call quitting_time when pressed: quit_button = tkinter.Button(root, text="Quit", command=quitting_time) ################################### # 5. SET UP PULLDOWN MENU OF FUNCTION CHOICES: ################################### # this variable holds the selected value from the menu menu_var = tkinter.StringVar(root) menu_var.set(OPTIONS[0]) # default value # create the optionmenu (pulldown menu) with the options above: option_menu = tkinter.OptionMenu(root, menu_var, *OPTIONS, command=show_instructions) ################################### # 6. PLACE EVERYTHING IN THE TKINTER WINDOW: # a "grid" allows you to turn the tkinter window into a series # of rows and columns and specifcy where to place everything ################################### # place the menu in the top left: option_menu.grid(row=0, column=0, columnspan=1) # place the buttons in the top middle: submit_button.grid(row=0, column=1, columnspan=1) quit_button.grid(row=0, column=2, columnspan=1) # sets up argument input boxes...ADD MORE IF YOU NEED THEM!!! entry_1 = tkinter.Entry() # makes an Entry object entry_2 = tkinter.Entry() entry_3 = tkinter.Entry() entry_4 = tkinter.Entry() # place the entry boxes in the next row, going across...ADD MORE IF NEEDED!!! entry_1.grid(row=1, column=0) entry_2.grid(row=1, column=1) entry_3.grid(row=1, column=2) entry_4.grid(row=1, column=3) # place the label in the next row (is just one row of text): results_label.grid(row=3, column=0, columnspan=4) # place the text areas in the next row (is a whole box of text): results_display.grid(row=4, column=0, columnspan=2) input_area.grid(row=4, column=2, columnspan=2) # make it so that words won't get broken up when reach end of text box: results_display.config(wrap=tkinter.WORD) input_area.config(wrap=tkinter.WORD) # waits for button clicks to take actions: root.mainloop()
def draw_lineitem(root, root_width, position, dict, key, title, padx, width=500): """ This displays a line of the monsters abilities: e.g. Skills, Languages etc. Variables: root: The object that the line is being drawn in. root_width: The pixel width of the root object. position: The row the line is being drawn in suing the tkinter.object.grid() packing procedure. dict: The dictionary that contains the lines value to display. key: The key for the value of the line we wish to display. title: The name of the stat to be displayed. i.e what is displayed in column 0. padx: The number of pixels to pad the text by in the x direction. width: The pixel width of the text row (not the title) to determine when to wrap onto the second line """ lookup = classes.Lookup() bold_font = Font(weight="bold", size=9) #========================= # If the key exists #========================= if key in dict: value = dict[key] tkinter.Label(root, anchor="ne", text=title, wraplength=root_width - width, font=bold_font).grid(row=position, column=0, sticky="ne", padx=padx) txt_str = "" if type(value) == str: #========================= # If before the dict value #========================= if key == "senses": txt_str += "{}, ".format(value) if key == "senses": txt_str += "passive perception {}".format(dict["passive"]) else: txt_str += value #========================= # If after the dict value #========================= if key == "cr": if "/" in value: split_value = value.split("/") value = int(split_value[0]) / int(split_value[1]) txt_str += " ({:,} XP)".format(lookup.cr_to_xp[float(value)]) else: for line in value: txt_str += "{}\n".format(line) tkinter.Label(root, anchor="w", justify="left", text=txt_str, wraplength=width).grid(row=position, column=1, sticky="w", padx=padx)
def get_font(self, size): name = f'font-{size}' if name not in self.assets: self.assets[name] = Font(size=size) return self.assets[name]
for i in range(2): keyboard.append([]) for j in range(10): keyboard[i].append(alphabet[10*i + j]) alphaCopy.remove(alphabet[10*i + j]) keyboard.append(alphaCopy) butH = 70 butW = 70 root = tk.Tk() root.geometry("1024x768") root.configure(background="white") myFont1 = Font(family="Calibri", size=50) myFont2 = Font(family="Calibri", size=20) state = "states/state_{}.png".format(6-death) hanging = ImageTk.PhotoImage(Image.open(state)) image = tk.Label(root, image=hanging, background = "white") image.place(x=600, y=60) currentGuess = tk.StringVar() currentGuess.set("".join(process)) guess = tk.Label(root, textvariable=currentGuess, font=myFont1) guess.place(x=keyboardX, y=keyboardY - 250) guess.configure(background="white") keyButtons = [] for i in range(len(keyboard)):
def __init__(self, window_ctrl, p1, p2): self.window_ctrl = window_ctrl self.p1 = p1 self.p2 = p2 frame_image = tk.Frame(self.window_ctrl.window) frame_image.pack() frame_image.configure(background='black') load = Image.open('visu/filimage.jpg') render = ImageTk.PhotoImage(load) img = tk.Label(frame_image, image=render, borderwidth=0) img.image = render img.pack() self.frame = tk.Frame(self.window_ctrl.window) self.frame.pack(expand=1) self.frame.configure(background='black') font = Font(family="Helvetica", size=20, weight="bold") label = tk.Label(self.frame, text=f"{self.p1.name}", fg=f"{self.p1.color}", font=font, justify='center', bg='black').pack() self.score_p1 = tk.StringVar() self.score_p1.set(f'{0}%') tk.Label(self.frame, textvariable=self.score_p1, fg=f"{self.p1.color}", font=font, justify='center', bg='black').pack() self.score_res = tk.StringVar() self.score_res.set(f'{0}') num = int(self.score_res.get()) tk.Label(self.frame, textvariable=self.score_res, fg=f"{self.p1.color}", font=font, justify='center', bg='black').pack() if self.p2: label = tk.Label(self.frame, text=f"\nVS\n", fg='white', font=font, justify='center', bg='black').pack() label = tk.Label(self.frame, text=f"{self.p2.name}", fg=f"{self.p2.color}", font=font, justify='center', bg='black').pack() self.score_p2 = tk.StringVar() self.score_p2.set(f'{0}%') tk.Label(self.frame, textvariable=self.score_p2, fg=f"{self.p2.color}", font=font, justify='center', bg='black').pack() self.score_res1 = tk.StringVar() self.score_res1.set(f'{0}') num1 = int(self.score_res1.get()) tk.Label(self.frame, textvariable=self.score_res1, fg=f"{self.p2.color}", font=font, justify='center', bg='black').pack() else: self.score_p2 = None
def __init__(self, root, callbacks, state, controller): self.root = root # Dict of callback names to callback data {**metadata, callback=func} style = ttk.Style(root) # set ttk theme to "clam" which support the fieldbackground option style.configure("Treeview", background=bg_color(), fieldbackground=bg_color()) style.configure("TPanedwindow", background=bg_color(), fieldbackground=bg_color()) self.callbacks = callbacks self.state = state self.controller = controller self.modes = {"Read", "Edit", "Visualize"} self.mode = "Read" self.frame = ttk.Frame(self.root) self.frame.pack(expand=True, fill="both") # Variables initialized below self.pane = None self.nav_frame = None self.nav_pane = None self.nav_tree = None self.nav_scrollbarx = None self.chapter_nav_frame = None self.chapter_nav_tree = None self.chapter_nav_scrollbarx = None self.main_pane = None self.alt_frame = None self.alt_textbox = None self.story_frame = None self.textbox_frame = None self.textbox = None # self.secondary_textbox_frame = None # self.secondary_textbox = None # self.preview_textbox_frame = None # self.preview_textbox = None self.vis_frame = None self.vis = None # self.multiverse_frame = None # self.multiverse = None self.panes = {'side_pane': None, 'bottom_pane': None} self.button_frame = None self.search_box = None self.search_frame = None self.search_label = None self.case_sensitive_checkbox = None self.case_sensitive = None self.search_results = None self.search_close_button = None self.buttons = {} self.back_button = None self.forward_button = None self.hoist_button = None self.unhoist_button = None self.nav_button_frame = None self.scroll_to_selected_button = None self.edit_textbox_icon = None self.font = Font(family='Georgia', size=12) self.font_bold = Font(family='Georgia', size=12, weight='bold') self.modules = {} # Build it! self.build_display(self.frame) self.set_mode(self.mode) self.icons = Icons()
from tkinter.font import Font import csv import matplotlib from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from skimage import io import pandas as pd from matplotlib import patches from tkinter.messagebox import * import time image1='' main = Tk() dir_path = os.path.dirname(os.path.realpath(__file__)) cwd = os.getcwd() print(cwd) os.chdir(dir_path) main.bold_font = Font(family="Helvetica", size=14, weight="bold") main.title("Image Encrypt Decrypt") main.minsize(800, 400) main.maxsize(800, 400) main.labelFrame = Label(main, text = "Open File:", font=('Impact', -20), bg='#000', fg='#000') main.labelFrame.grid(column = 0, row = 2, padx = 20, pady = 20) main.configure(background='#dfdddd') main.labelFrame.configure(background='#dfdddd') Label(main, text = "Enter Encryption Character for 0:").grid(column= 0, row = 4) Label(main, text = "Enter Encryption Character for 1:").grid(column= 0, row = 5) Label(main, text = "Enter Encryption Character for 2:").grid(column= 0, row = 6) Label(main, text = "Enter Encryption Character for 3:").grid(column= 0, row = 7) Label(main, text = "Enter Encryption Character for 4:").grid(column= 0, row = 8) Label(main, text = "Enter Encryption Character for 5:").grid(column= 0, row = 9) Label(main, text = "Enter Encryption Character for 6:").grid(column= 0, row = 10)
main_menu.add_cascade(menu=view_menu,label="View") view_menu.add_command(label="Full Screen",command=fullscreen,accelerator="ALT+Q") view_menu.add_command(label="Custom Screen Size",command=customscreen,accelerator="ALT+W") view_menu.add_command(label="Change Background Color",command=bgcolor) #creating page layout menu page_menu=Menu(main_menu) main_menu.add_cascade(menu=page_menu,label="Page Layout") page_menu.add_command(label="contents",command=pagelayout,accelerator="ALT+i") my_font = Font(family="ALGERIAN", size=32, weight="bold") root_label1=Label(root,text="ATTENDANCE",font=my_font,bd=10,bg="#edf2f9",width=root.winfo_width()//4) root_label1.grid(row=0,column=0,columnspan=100) x_image_for_button = PhotoImage(file='man.png') x_image_for_button1 = PhotoImage(file='img1.png') root_b1=Button(root,image=x_image_for_button,width=140,height=140,command=manual,relief=SOLID) root_b1.grid(row=2,column=1,pady=10) root_b2=Button(root,image=x_image_for_button1,width=140,height=140,command=open_file,relief=SOLID) root_b2.grid(row=3,column=1) root_label2=Label(root,text="Status Bar",width=40,bg="gray",fg="black",font=Font(family="Arial", size=11, weight="bold")) root_label2.grid(row=4,column=0,columnspan=7,pady=20,sticky="s") status_t=[None]*7 status_l=[None]*6 for j in range(6): status_t[j]=Text(root,width=30,height=1)
def __init__(self, master): self.mode = IntVar() self.ibuffer = "" self.piflag = False # telemetry array =========================================== data = Frame(master) data.place(x=20,y=470) sta=Label(data,text="STS:", font=(None,15)) sta.grid(row=0,column=0) spd=Label(data,text="SPD:", font=(None,15)) spd.grid(row=1,column=0) hdg=Label(data,text="HDG:", font=(None,15)) hdg.grid(row=2,column=0) ste=Label(data,text="STR:", font=(None,15)) ste.grid(row=3,column=0) dtgl=Label(data,text="DTG:", font=(None,15)) dtgl.grid(row=4,column=0) ctgl=Label(data,text="CTG:", font=(None,15)) ctgl.grid(row=5,column=0) xtel=Label(data,text="XTE:", font=(None,15)) xtel.grid(row=6,column=0) lat=Label(data,text="ACC:", font=(None,15)) lat.grid(row=7,column=0) self.status = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.status).grid(row=0,column=1) self.speed = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.speed).grid(row=1,column=1) self.head = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.head).grid(row=2,column=1) self.steer = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.steer).grid(row=3,column=1) self.dtg = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.dtg).grid(row=4,column=1) self.ctg = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.ctg).grid(row=5,column=1) self.xte = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.xte).grid(row=6,column=1) self.acc = StringVar() Label(data,width=5,font=(None,20),bg="white",fg="blue", \ borderwidth=1,relief="solid",\ textvariable=self.acc).grid(row=7,column=1) # Steering button array ======================================== steer = Frame(master) steer.place(x=550,y=700) l35 = Button(steer, text="<<<", command = lambda:self.dxmit('7')) l35.config(width=3,height=1,font=(None,15),bg="pink",fg="black",borderwidth=4) l35.grid(row=0,column=0) l5 = Button(steer, text="<<", command = lambda:self.dxmit('4')) l5.config(width=3,height=1,font=(None,15),bg="pink",fg="black",borderwidth=4) l5.grid(row=0,column=1) l1 = Button(steer, text="<", command = lambda:self.dxmit('1')) l1.config(width=3,height=1,font=(None,15),bg="pink",fg="black",borderwidth=4) l1.grid(row=0,column=2) z0 = Button(steer, text=".", command = lambda:self.dxmit('5')) z0.config(width=3,height=1,font=(None,25),bg="linen",fg="black",borderwidth=4) z0.grid(row=0,column=3) r1 = Button(steer, text=">", command = lambda:self.dxmit('3')) r1.config(width=3,height=1,font=(None,15),bg="green2",fg="black",borderwidth=4) r1.grid(row=0,column=4) r5 = Button(steer, text=">>", command = lambda:self.dxmit('6')) r5.config(width=3,height=1,font=(None,15),bg="green2",fg="black",borderwidth=4) r5.grid(row=0,column=5) r35 = Button(steer, text=">>>", command = lambda:self.dxmit('9')) r35.config(width=3,height=1,font=(None,15),bg="green2",fg="black",borderwidth=4) r35.grid(row=0,column=6) # speed button array =================================================== speed = Frame(master) speed.place(x=1150, y=500) fmax = Button(speed, text = "+", command = lambda:self.dxmit('2')) fmax.config(width = 3, height = 2, font=(NONE,15), \ bg="green2",fg="black",borderwidth=4) fmax.grid(row=0,column=0) f0 = Button(speed, text = "0", command = lambda:self.dxmit('0')) f0.config(width = 3, height = 4, font=(NONE,15), \ bg="linen",fg="black",borderwidth=4) f0.grid(row=3,column=0) rmax = Button(speed, text = "-", command = lambda:self.dxmit('8')) rmax.config(width = 3, height = 2, font=(NONE,15), \ bg="pink",fg="black",borderwidth=4) rmax.grid(row=6,column=0) # mode menu =========================================================== radio = Frame(master) radio.place(x=20, y=20) rb1 = Radiobutton(radio, text="Standby", variable=self.mode, value = 0, \ anchor=W, command=lambda:self.mode_set(master, self.mode.get())) rb1.config(width = 7, height = 2, font=(NONE,15)) rb1.grid(row=0, column=0) rb2 = Radiobutton(radio, text="Auto", variable=self.mode, value = 1, \ anchor=W, command=lambda:self.mode_set(master, self.mode.get())) rb2.config(width = 6, height = 2, font=(NONE,15)) rb2.grid(row=1, column=0) rb3 = Radiobutton(radio, text="Path", variable=self.mode, value = 2, \ anchor=W, command=lambda:self.mode_set(master, self.mode.get())) rb3.config(width = 6, height = 2, font=(NONE,15)) rb3.grid(row=2, column=0) rb4 = Radiobutton(radio, text="PanTilt", variable=self.mode, value = 3, \ anchor=W, command=lambda:self.mode_set(master, self.mode.get())) rb4.config(width = 6, height = 2, font=(NONE,15)) rb4.grid(row=3, column=0) rb5 = Radiobutton(radio, text="Misc", variable=self.mode, value = 4, \ anchor=W, command=lambda:self.mode_set(master, self.mode.get())) rb5.config(width = 6, height = 2, font=(NONE,15)) rb5.grid(row=4, column=0) # enlarge button array =================================================== zoom = Frame(root) zoom.place(x=825, y=200) fmax = Button(zoom, text = "+", command = lambda:scaler(1)) fmax.config(width = 1, height = 1, font=(NONE,15), \ bg="green2",fg="black",borderwidth=4) fmax.grid(row=0,column=0) rmax = Button(zoom, text = "-", command = lambda:scaler(-1)) rmax.config(width = 1, height = 1, font=(NONE,15), \ bg="pink",fg="black",borderwidth=4) rmax.grid(row=1,column=0) rmax = Button(zoom, text = "X", command = lambda:scaler(0)) rmax.config(width = 1, height = 1, font=(NONE,15), \ bg="deep sky blue",fg="black",borderwidth=4) rmax.grid(row=2,column=0) def scaler(scl): global mode mode = scl # # compass rose ============================================================ rose.create_oval(25, 25, 195, 195, width=1, outline='black', fill="black") ffont = Font(family="URW Chancery L", size=20, weight = "bold") efont = Font(family="URW Chancery L", size=16) rose.create_text(108, 8, text="N", font = ffont, angle=0) rose.create_text(105, 210, text="S", font = ffont, angle=0) rose.create_text(8, 112, text="W", font = ffont, angle=90) rose.create_text(212, 108, text="E", font = ffont, angle=270) rose.create_text(180, 40, text = "NE", font = efont, angle=315) rose.create_text(185, 175, text = "SE", font = efont, angle=225) rose.create_text(45, 180, text = "SW", font = efont, angle=135) rose.create_text(45, 40, text = "NW", font = efont, angle=45)
def drawCells(self): global Initial_data if self.ck_done(): return cv = self.cv xmin = self.xMin xmax = self.xMax ymin = self.yMin ymax = self.yMax # Separator line attributes # (Canvas createLine) cell_opt_h = {'width':self.cellSep, 'fill':self.cellSepFg} group_opt_h = {'width':self.groupSep, 'fill':self.groupSepFg} row_lines = self.getDividers(type="row", cell=self.data.nRow, group=self.data.nSubRow, min=ymin, max=ymax, cellOpt=cell_opt_h, groupOpt=group_opt_h) col_lines = self.getDividers(type="col", cell=self.data.nCol, group=self.data.nSubCol, min=xmin, max=xmax, cellOpt=cell_opt_h, groupOpt=group_opt_h) rowSize = self.rowSize colSize = self.colSize # Setup board font bdFont = Font(family=self.bdFontName, size=(colSize-1)) self.bdFont = bdFont # Setup cells for data display, selection Initial_data = self.initialData # TBD: Set up clickCell to obtain entry from event position for ri in range(len(row_lines)): row = ri+1 r_l1 = row_lines[ri].args # [x1,y1,x2,y2] y1 = r_l1[1] y2 = y1 + rowSize for ci in range(len(col_lines)): col = ci+1 c_l1 = col_lines[ci].args # [x1,y1,x2,y2] x1 = c_l1[0] x2 = x1 + colSize if row <= self.data.nRow and col <= self.data.nCol: self.setCell(row=row, col=col, x1=x1, y1=y1, x2=x2, y2=y2) ''' if self.initialData is not None: orig_val = self.initialData.getCell(row, col) if orig_val is not None: self.markCell(row=row, col=col, tag='origData', add=1, boundWidth='NONE', boundColor='NONE', backColor="gray90") ''' # Mark squares for r_line in row_lines: cv.create_line(r_line.args, r_line.kwargs) for r_line in col_lines: cv.create_line(r_line.args, r_line.kwargs)
def __init__(self, parent): ttk.Frame.__init__(self, parent) self.pane = ttk.PanedWindow(self, orient='horizontal') self.pane.grid(column=0, row=0, sticky='nwes') self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) left = ttk.Frame(self.pane, padding=5) self.pane.add(left) controls = ttk.Frame(left) f = Font(name='TkSmallCaptionFont', exists=True, root=self._root()) fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), "Icons", "debug_go.gif") self.goimg = PhotoImage(master=self._root(), file=fn) fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), "Icons", "debug_step.gif") self.stepimg = PhotoImage(master=self._root(), file=fn) fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), "Icons", "debug_over.gif") self.overimg = PhotoImage(master=self._root(), file=fn) fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), "Icons", "debug_out.gif") self.outimg = PhotoImage(master=self._root(), file=fn) fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), "Icons", "debug_stop.gif") self.stopimg = PhotoImage(master=self._root(), file=fn) go = ttk.Label(controls, image=self.goimg, text='Go', compound='top', font=f) step = ttk.Label(controls, image=self.stepimg, text='Step', compound='top', font=f) over = ttk.Label(controls, image=self.overimg, text='Over', compound='top', font=f) out = ttk.Label(controls, image=self.outimg, text='Out', compound='top', font=f) stop = ttk.Label(controls, image=self.stopimg, text='Stop', compound='top', font=f) go.grid(column=0, row=0, padx=[0,5]) step.grid(column=1, row=0, padx=[0,5]) over.grid(column=2, row=0, padx=[0,5]) out.grid(column=3, row=0, padx=[0,5]) stop.grid(column=4, row=0, padx=[0,5]) self.status = ttk.Label(controls, text='Program stopped by exception.', foreground='#ff0000', font=('helvetica', 13, 'italic')) self.status.grid(column=5, row=0, padx=[50,0]) controls.grid(column=0, row=0, sticky='nw', pady=[0,6]) #self.stack = Text(left, height=5, highlightthickness=0) #self.stack.insert(END, "__init__ [uipreferences.py:163]\nadd_panes [uipreferences.py:180]\n__init__ [uipreferences.py:424]\nrebuild_themes_list [uipreferences.py:433]\ntheme_changed [uipreferences.py:443]\nupdate_colors [uipreferences.py:477]") self.stack = ttk.Treeview(left, columns=('location', 'statement'), displaycolumns=('statement',), height=5) self.stack.insert('', 'end', text='__init__', values=('[__main__:163]', 'self.add_panes(tabs)')) self.stack.insert('', 'end', text='add_panes', values=('[__main__.py:180]', "self.add_pane(ThemesPane(parent, self), 'Themes')")) self.stack.insert('', 'end', text='__init__', values=('[__main__.py:424]', "self.rebuild_themes_list()")) self.stack.insert('', 'end', text='rebuild_themes_list', values=('[__main__.py:433]', "self.theme_changed()")) self.stack.insert('', 'end', text='theme_changed()', values=('[__main__.py:443]', "self.update_colors()")) self.stack.insert('', 'end', text='update_colors()', values=('[__main__.py:477]', "x = 5/0")) self.stack.insert('', 'end', text='ZeroDivisionError:', values=('', "division by zero"), tags=('error',)) self.stack.tag_configure('error', foreground='red') scroll = ttk.Scrollbar(left, command=self.stack.yview) self.stack['yscrollcommand'] = scroll.set self.stack.grid(column=0, row=1, sticky='nwes') scroll.grid(column=1, row=1, sticky='ns') left.grid_columnconfigure(0, weight=1) left.grid_rowconfigure(1, weight=1) right = ttk.Frame(self.pane, padding=5) self.pane.add(right) tree = ttk.Treeview(right, columns=('value',), height=5) locals = tree.insert('', 'end', text='Locals') globals = tree.insert('', 'end', text='Globals') tree.insert(locals, 'end', text='bg', values=("'#ffffff'",)) tree.insert(locals, 'end', text='element', values=("'Shell Normal Text'", )) tree.insert(locals, 'end', text='elt', values=("'console'",)) tree.insert(locals, 'end', text='fg', values=("'#770000'",)) tree.insert(locals, 'end', text='self', values="<__main__.ThemesPane object...28896.4437729008.4437729232>") tree.insert(locals, 'end', text='theme', values=("'IDLE Classic'",)) tree.insert(globals, 'end', text='One',) tree.insert(globals, 'end', text='Two',) tree.insert(globals, 'end', text='Three',) tree.grid(column=0, row=0, sticky='nwes') right.grid_columnconfigure(0, weight=1) right.grid_rowconfigure(0, weight=1)
"https://www.googleapis.com/auth/drive" ] creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope) client = gspread.authorize(creds) sheet = client.open("demosheet").worksheet("1") # sheet = client.open("demosheet").sheet1 root = Tk() root.title('Spreadsheet') root.geometry("400x600") # Define fonts headings = Font(family="Impact", size=22, weight="bold") normal = Font(family="Helvetica", size=19, weight="normal") def update(*args): x = enterInfo.get() x = x.split() date = int(x[0]) price = int(x[1]) print(x) nameSelected = clicked.get() priceStr = str(price) dateStr = str(date)
def __init__(self, parent): from menu import declare_an_image_for_a_widget, bind_events_for_widget from menu import MenuWindow tk.Frame.__init__(self, parent) self.font = Font(family='Small Fontz', size=20) self.bg_color = '#363747' self.parent = parent self.config(bg=self.bg_color) def enter_to_label(label): if label == 'easy': self.easy_mode.config(image=self.easy_mode_cursor_on_image) self.easy_mode_label.config(fg='#5ef6c1') self.easy_mode.is_cursor_on = True elif label == 'medium': self.medium_mode.config(image=self.medium_mode_cursor_on_image) self.medium_mode_label.config(fg='#f5a77c') self.medium_mode.is_cursor_on = True elif label == 'hard': self.hard_mode.config(image=self.hard_mode_cursor_on_image) self.hard_mode_label.config(fg='#fd7e92') self.hard_mode.is_cursor_on = True elif label == 'go_back': self.go_back.config(image=self.go_back_cursor_on_image) self.go_back.is_cursor_on = True def leave_label(label): if label == 'easy': self.easy_mode_label.config(fg='#01d185') self.easy_mode.config(image=self.easy_mode_image) self.easy_mode.is_cursor_on = False elif label == 'medium': self.medium_mode_label.config(fg='#ee8245') self.medium_mode.config(image=self.medium_mode_image) self.medium_mode.is_cursor_on = False elif label == 'hard': self.hard_mode_label.config(fg='#fc607d') self.hard_mode.config(image=self.hard_mode_image) self.hard_mode.is_cursor_on = False elif label == 'go_back': self.go_back.config(image=self.go_back_image) self.go_back.is_cursor_on = False def press_label(label): if label == 'easy': self.easy_mode.config(image=self.easy_mode_pressed_image) elif label == 'medium': self.medium_mode.config(image=self.medium_mode_pressed_image) elif label == 'hard': self.hard_mode.config(image=self.hard_mode_pressed_image) elif label == 'go_back': self.go_back.config(image=self.go_back_pressed_image) def release_label(label): if label == 'easy': if self.easy_mode.is_cursor_on: start_game(label) elif label == 'medium': if self.medium_mode.is_cursor_on: start_game(label) elif label == 'hard': if self.hard_mode.is_cursor_on: start_game(label) elif label == 'go_back': if self.go_back.is_cursor_on: return_to_menu() def start_game(difficulty): self.destroy() game = PlayWindow(self.parent, False, difficulty) game.grid() def return_to_menu(): self.destroy() menu = MenuWindow(self.parent) menu.grid(sticky='NSEW') # List of all the images used in this widget, 'image route', 'size', atributte name' images = [ ['Images/easy_face.png', (110, 110), 'easy_mode_image'], [ 'Images/easy_face_cursor_on.png', (110, 110), 'easy_mode_cursor_on_image' ], [ 'Images/easy_face_pressed.png', (110, 110), 'easy_mode_pressed_image' ], ['Images/medium_face.png', (110, 110), 'medium_mode_image'], [ 'Images/medium_face_cursor_on.png', (110, 110), 'medium_mode_cursor_on_image' ], [ 'Images/medium_face_pressed.png', (110, 110), 'medium_mode_pressed_image' ], ['Images/hard_face.png', (110, 110), 'hard_mode_image'], [ 'Images/hard_face_cursor_on.png', (110, 110), 'hard_mode_cursor_on_image' ], [ 'Images/hard_face_pressed.png', (110, 110), 'hard_mode_pressed_image' ], [ 'Images/choose_difficulty.png', (500, 80), 'choose_difficulty_image' ], ['Images/go_back.png', (80, 80), 'go_back_image'], [ 'Images/go_back_cursor_on.png', (80, 80), 'go_back_cursor_on_image' ], ['Images/go_back_pressed.png', (80, 80), 'go_back_pressed_image'], ] for image in images: declare_an_image_for_a_widget(self, image[0], image[1], image[2]) # Widget's cursor functions for binding self.binding_functions = [ enter_to_label, leave_label, press_label, release_label ] # Difficulties title label self.difficulties = tk.Label(self, relief=FLAT, bg=self.bg_color, height=80, width=500, image=self.choose_difficulty_image) self.difficulties.grid(row=0, column=0, pady=(15, 40), padx=(20, 0), columnspan=3) # Easy mode label self.easy_mode = tk.Label(self, relief=FLAT, bg=self.bg_color, image=self.easy_mode_image, font=self.font) self.easy_mode.grid(row=2, column=0, padx=(50, 30)) bind_events_for_widget(self.easy_mode, self.binding_functions, 'easy') self.easy_mode_label = tk.Label(self, relief=FLAT, bg=self.bg_color, fg='#01d185', text='Easy', font=self.font) self.easy_mode_label.grid(row=3, column=0, padx=(20, 0)) # Medium mode label self.medium_mode = tk.Label(self, bg=self.bg_color, relief=FLAT, image=self.medium_mode_image, font=self.font) self.medium_mode.grid(row=2, column=1, padx=30) bind_events_for_widget(self.medium_mode, self.binding_functions, 'medium') self.medium_mode_label = tk.Label(self, relief=FLAT, bg=self.bg_color, fg='#ee8245', text='Medium', font=self.font) self.medium_mode_label.grid(row=3, column=1, padx=(0, 5)) # Hard mode label self.hard_mode = tk.Label(self, bg=self.bg_color, relief=FLAT, text='Hard', font=self.font, image=self.hard_mode_image) self.hard_mode.grid(row=2, column=2, padx=(20, 40)) bind_events_for_widget(self.hard_mode, self.binding_functions, 'hard') self.hard_mode_label = tk.Label(self, relief=FLAT, bg=self.bg_color, fg='#fc607d', text='Hard', font=self.font) self.hard_mode_label.grid(row=3, column=2, padx=(0, 20)) # Go back arrow label self.go_back = tk.Label(self, bg=self.bg_color, relief=FLAT, image=self.go_back_image) self.go_back.grid(row=5, column=0, pady=(0, 20), padx=(0, 60)) bind_events_for_widget(self.go_back, self.binding_functions, 'go_back') self.grid_rowconfigure(4, weight=2)
def save_tasks(): """ uses the pickle module to dump the items collected from the listbox and write it into a file """ tasks = lst_tasks.get(0, lst_tasks.size()) if tasks: pickle.dump(tasks, open("tasks.dat", "wb")) else: msg.showwarning('alert', 'nothing to save') #defining a Font my_font = Font(family="monospace", size="10", weight="bold") #storing our entry input task_input = tk.StringVar() Todo_label = tk.Label(win, text="Todo list", height=3, width=50, bg="green", fg="white", font=my_font, bd=0) Todo_label.pack() #creating a frame to pack the list and the scrollbar into frame = tk.Frame(win) frame.pack()
def show(conf_values, build_values): """ Invoked from the main python file danmachi_builder.py to draw the master tkinter window. Variables: conf_values: A Conf class object. build_values: A Build class object. """ window = tkinter.Tk() # Set the master window title (N.B: version is set from the danmachi_builder.py file) window.title( "DanMachi Encounter Builder - Ver: {} - Author: Harry Tunstall".format( conf_values.version)) draw_icon(window, conf_values) # Set master window size window.minsize(width=min_width, height=min_height) window.resizable(width=True, height=True) # Set the size of the larger font l_font = Font(family='Helvetica', size=13) # Unlucky for some #-------------------------------------------------------------------------- # Tkinter Variables #-------------------------------------------------------------------------- floor = tkinter.IntVar() # Party level size = tkinter.IntVar() # Party size level = tkinter.IntVar() # Party level drop_chance = tkinter.IntVar() # number at which drops occour drop_chance.set(conf_values.drop_chance) cr_zero = tkinter.BooleanVar() # Are we haveing CR 0 monsters cr_zero.set(build_values.cr_zero) dc_easy = tkinter.IntVar() # DC at whcih monsters dont spawn dc_easy.set(build_values.dc_easy) dc_rolled = tkinter.IntVar() # number at which drops occour dc_rolled.set(build_values.dc_rolled) #-------------------------------------------------------------------------- # Top Frame #-------------------------------------------------------------------------- top_frame = tkinter.Frame(window) top_frame.pack(side="top", anchor="w", padx=xpad, pady=ypad, ipadx=ixpad, ipady=iypad) #-------------------------------------------------------------------------- # Build Information Frame #-------------------------------------------------------------------------- build_info = tkinter.LabelFrame(top_frame, text="Build Information") build_info.pack(side="top", anchor="w", padx=xpad, pady=ypad, ipadx=ixpad, ipady=iypad) #-------------------------------------------------------------------------- # Dungeon Information Frame #-------------------------------------------------------------------------- floor_frame = tkinter.LabelFrame(build_info, text="Dungeon") floor_frame.grid(row=0, column=0, padx=xpad, pady=ypad) # Floor Number floor_lb = tkinter.Label(floor_frame, text="Floor: ", pady=ypad) floor_lb.pack(side="left") floor_box = tkinter.Spinbox(floor_frame, from_=1, to=49, width=2, state="readonly", textvariable=floor, font=l_font) floor_box.pack(side="left") # CR 0 Monsters Check Box cr_zero_bt = tkinter.Checkbutton(floor_frame, text="Allow CR 0 Monsters", variable=cr_zero, onvalue=True, offvalue=False) cr_zero_bt.pack(side="left", padx=xpad, pady=ypad - 3) if build_values.cr_zero == True: cr_zero_bt.select() else: cr_zero_bt.deselect() #-------------------------------------------------------------------------- # Party Frame #-------------------------------------------------------------------------- party_frame = tkinter.LabelFrame(build_info, text="Party") party_frame.grid(row=0, column=1, padx=xpad, pady=ypad) # Size size_lb = tkinter.Label(party_frame, text="Size: ", pady=ypad) size_lb.pack(side="left") size_box = tkinter.Spinbox(party_frame, from_=1, to=8, width=2, state="readonly", textvariable=size, font=l_font) size_box.pack(side="left", padx=xpad, pady=ypad - 3) # Level level_lb = tkinter.Label(party_frame, text="level: ") level_lb.pack(side="left") level_box = tkinter.Spinbox(party_frame, from_=1, to=20, width=2, state="readonly", textvariable=level, font=l_font) level_box.pack(side="left", padx=xpad, pady=ypad - 3) # Drop Chance drop_chance_lb = tkinter.Label(party_frame, text=" Drop Chance: ", pady=ypad) drop_chance_lb.pack(side="left") drop_chance_box = tkinter.Spinbox(party_frame, from_=1, to=20, width=2, state="readonly", textvariable=drop_chance, font=l_font) drop_chance_box.pack(side="left", padx=xpad, pady=ypad - 3) #-------------------------------------------------------------------------- # Difficulty Frame #-------------------------------------------------------------------------- diff_frame = tkinter.LabelFrame(build_info, text="Difficulty") diff_frame.grid(row=1, column=0, columnspan=2, padx=xpad, sticky="w") # DC Encounter dc_easy_lb = tkinter.Label(diff_frame, text="DC for Encounter: ", pady=ypad) dc_easy_lb.grid(row=0, column=0, sticky="e") dc_easy_spin = tkinter.Spinbox( diff_frame, from_=10, to=20, width=2, state="readonly", textvariable=dc_easy, font=l_font, command=lambda: update_ui(dc_slider, dc_rolled_spin, dc_easy.get() - 1)) dc_easy_spin.grid(row=0, column=1) # DC Rolled dc_rolled_lb = tkinter.Label(diff_frame, text="DC Rolled: ", pady=ypad) dc_rolled_lb.grid(row=1, column=0, sticky="e") dc_rolled_spin = tkinter.Spinbox(diff_frame, from_=1, to=dc_easy.get() - 1, width=2, state="readonly", textvariable=dc_rolled, font=l_font) dc_rolled_spin.grid(row=1, column=1) dc_slider = tkinter.Scale(diff_frame, from_=1, to=dc_easy.get() - 1, variable=dc_rolled, orient=tkinter.HORIZONTAL, length=200, showvalue=False) dc_slider.grid(row=1, column=2, sticky="e") #-------------------------------------------------------------------------- # Controls Frame #-------------------------------------------------------------------------- master_butons = tkinter.LabelFrame(window, text="Controls") master_butons.pack(side="top", anchor="w", padx=xpad, pady=ypad, ipadx=ixpad, ipady=iypad) # Build Button build_bt = tkinter.Button( master_butons, text="Build Encounter", command=lambda: build_click(logbox, conf_values, build_values, level.get(), size.get(), floor.get(), drop_chance.get(), cr_zero.get(), dc_easy.get(), dc_rolled.get())) build_bt.pack(side="left", anchor="w", padx=xpad, pady=ypad) # Wipe Log Button wipe_lb_bt = tkinter.Button(master_butons, text="Wipe Event Log", command=lambda: wipe_log(logbox, build_values)) wipe_lb_bt.pack(side="left", anchor="w", padx=xpad, pady=ypad) # Show monster stats Button stats_bt = tkinter.Button( master_butons, text="Show Monster Stats", command=lambda: show_monster_stats_ui(build_values, conf_values)) stats_bt.pack(side="left", anchor="w", padx=xpad, pady=ypad) # Show monster stats Button info_bt = tkinter.Button( master_butons, text="Additional Information", command=lambda: tkinter.messagebox.showinfo( "Info", "Please look at the documentation at the bottom of the README.md.\nThe formatting is easiest to view on GitHub." )) info_bt.pack(side="left", anchor="w", padx=xpad, pady=ypad) #-------------------------------------------------------------------------- # Event Log Frame #-------------------------------------------------------------------------- log_frame = tkinter.LabelFrame(window, text="Event Log") log_frame.pack(side="top", anchor="w", fill="both", expand=1, padx=xpad, pady=ypad, ipadx=ixpad, ipady=iypad) # ScrolledText log box logbox = ScrolledText(log_frame, undo=True, borderwidth=3, wrap='word', state="disabled") logbox.pack(fill="both", expand=1, side="top", padx=xpad, pady=ypad) window.mainloop()
def post_run(status_num): global root notebook.destroy() large_font = Font(family="Times", size=14) med_font = Font(family="Times", size=12) post_run_frame = Frame(root) post_run_frame.pack() frame = LabelFrame(post_run_frame, padx=5, pady=5, borderwidth=0, highlightthickness=0) frame.grid(row=1, column=0, padx=10, pady=(0, 10)) frame2 = LabelFrame(post_run_frame, padx=5, pady=5) frame2.grid(row=2, column=0, padx=20, pady=(0, 10)) def run_again(): reset() post_run_frame.destroy() main_window() def show_xlsx(event=None): os.system("start \"\" \"" + save_path + "\"") def show_error(): os.system("start \"\" \"" + log_file + "\"") if (status_num == 0): if autorun_output.get(): show_xlsx() Label(post_run_frame, text='Program Finished Successfully!', font=large_font).grid(row=0, column=0, padx=10, pady=10) Label(frame2, text='Output Location:', font=med_font).grid(row=1, column=0, padx=10, pady=(3, 0)) save_entry = Entry(frame2, width=90) save_entry.grid(row=2, column=0) save_entry.insert(0, save_path) save_entry.configure(state='readonly') Button(frame, text="Exit", command=exit_prog, padx=38, pady=2).grid(row=1, column=0, padx=25) Button(frame, text="Run Again", command=run_again, padx=26, pady=2).grid(row=1, column=1, padx=25) Button(frame, text="Open Output", command=show_xlsx, padx=20, pady=2).grid(row=1, column=2, padx=25) else: Button(frame, text="Exit", command=exit_prog, padx=38, pady=2).grid(row=1, column=0, padx=2) Button(frame, text="Run Again", command=run_again, padx=26, pady=2).grid(row=1, column=1, padx=2) Button(frame, text="Help", command=help, padx=20, pady=2).grid(row=1, column=2, padx=2) if (status_num == 2): Label(post_run_frame, text='ERROR 2: Bad input file', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 3): Label(post_run_frame, text='ERROR 3: Bad output file', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 4): Label(post_run_frame, text='ERROR 4: Bad topic file', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 5): Label(post_run_frame, text='ERROR 5: Bad subtopic file', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 6): Label(post_run_frame, text='ERROR 6: Failed reading topic or subtopic', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 7): Label(post_run_frame, text='ERROR 7: Failed to sort input file', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 8): Label(post_run_frame, text='ERROR 8: Unsupported file type', font=large_font).grid(row=0, column=0, padx=10, pady=10) elif (status_num == 9): Label(post_run_frame, text= 'ERROR 9: Mismatch Topic and Subtopic files check log file', font=large_font).grid(row=0, column=0, padx=10, pady=10) show_error() else: Label(post_run_frame, text='ERROR 50: Uncaught Exception', font=large_font).grid(row=0, column=0, padx=10, pady=10) post_run_frame.bind('<Return>', show_xlsx) root.protocol("WM_DELETE_WINDOW", exit_prog) post_run_frame.mainloop()
def __init__(self): global style, tabnow #initialize the font self.titlefont = Font(size=30, family='Bahnschrift SemiBold') self.cases_label_font = Font(size=60, family='Bahnschrift') #initialize all the variable self.frame1 = Frame(root, bg='#696969') self.frame2 = Frame(root, bg='#696969') self.frame3 = Frame(root, bg='#696969') self.cases_num = total_cases_num() self.total_cases_numm = int(self.cases_num[0].replace(' ', '').replace( ',', '')) self.total_death_numm = int(self.cases_num[1].replace(' ', '').replace( ',', '')) self.total_recovered_numm = int(self.cases_num[2].replace(' ', '').replace( ',', '')) self.total_cases_num_title = Label(self.frame1, text='Total Cases', font=self.titlefont, bg='#696969', fg='white') self.death_num_title = Label(self.frame2, text='Total Deaths', font=self.titlefont, bg='#696969', fg='white') self.recovered_num_title = Label(self.frame3, text='Total Revovered', font=self.titlefont, bg='#696969', fg='white') self.total_cases_label = Label(self.frame1, text=self.total_cases_numm, font=self.cases_label_font, bg='#696969', fg='white') self.total_death_label = Label(self.frame2, text=self.total_death_numm, font=self.cases_label_font, bg='#696969', fg='white') self.total_recovered_label = Label(self.frame3, text=self.total_recovered_numm, font=self.cases_label_font, bg='#696969', fg='white') style.configure("Treeview", highlightthickness=0, rowheight=40, bd=0, font=('Bahnschrift', 15), background="#191919", fieldbackground="white", foreground="white") # Modify the font of the body style.layout("Treeview", [('mystyle.Treeview.treearea', { 'sticky': 'nswe' })]) # Remove the borders self.column_names = ("1", '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15') self.table = ttk.Treeview(root, column=self.column_names, style="Treeview", height=10, show="tree", selectmode='none') self.table.column('#0', width=0, minwidth=0, stretch=NO) self.table.column('1', width=50, minwidth=50, stretch=NO, anchor='e') self.table.column('2', width=230, minwidth=230, stretch=NO) [ self.table.column(str(i), width=110, minwidth=110, stretch=NO, anchor='e') for i in range(3, 15) ] self.table.column(15, width=130, minwidth=130, stretch=NO, anchor='e') self.header = [ 'No.', 'Country/\nOthers', 'Total\nCases', 'New\nCases', 'Total\nDeaths', 'New\nDeaths', 'Total\nRecovered', 'New\nRecovered', 'Active\nCases', 'Serious,\nCritical', 'Cases/\n1M pop', 'Deaths/\n1M pop', 'Total\nTests', 'Tests/\n1M pop', 'Population' ] self.heading = [ Label(root, text=i, font=Font(size=15, family='Bahnschrift'), bg='#191919', fg='white', anchor='e', justify=RIGHT) for i in self.header ] self.tableheadingline = Label(bg='#555555') self.coronatable = gettable() [ self.table.insert("", END, values=[i + 1] + [' ' + str(a) for a in self.coronatable[i]]) for i in range(len(self.coronatable)) ] self.tablevsb = ttk.Scrollbar(root, orient="vertical", command=self.table.yview) self.table.configure(yscrollcommand=self.tablevsb.set)
def __init__(self, master, *args, **kwargs): # Initialize the instance ttk.Frame.__init__(self, master, *args, **kwargs) self.master.title('Setup') self.master.protocol('WM_DELETE_WINDOW', self.__close) self.master.minsize(width=500, height=300) self.master.resizable(False, False) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.rowconfigure(1, weight=0) # Configure styles welcome_title_font = Font(family="Ariel", size=20, underline=True) welcome_text_font = Font(family="Ariel", size=12) char_count_font = Font(family="Ariel", size=8) style = ttk.Style() style.configure('WelcomeWindowTitle.TLabel', anchor=tk.CENTER, font=welcome_title_font) style.configure('WelcomeWindow.TLabel', font=welcome_text_font) style.configure('WelcomeWindow.TEntry', font=welcome_text_font) style.configure('CharacterCount.TLabel', font=char_count_font) # First page of the welcome window self.page_one = RegistrationPageOne(self, welcome_text_font) self.page_one.grid(column=0, row=0, sticky=tk.NSEW) # Second page of welcome window self.page_two = RegistrationPageTwo(self) self.page_two.grid(column=0, row=0) self.page_two.grid_remove() # Final page of the welcome window self.final_page = RegistrationFinalPage(self, welcome_text_font) self.final_page.grid(column=0, row=0) self.final_page.grid_remove() self.current_page = self.page_one # Button for going to next page in welcome sequence self.next_btn = ttk.Button(self, text='Next', command=lambda: self.__next()) self.next_btn.grid(column=0, row=1, pady=(10, 10), sticky=tk.S) self.next_btn.focus_set() self.next_btn.bind('<Return>', self.__next) # Place window in the center of the screen self.master.update_idletasks() w = self.master.winfo_width() h = self.master.winfo_height() wscreen = self.winfo_screenwidth() hscreen = self.winfo_screenheight() x = (wscreen / 2) - (w / 2) y = (hscreen / 2) - (h / 2) self.master.geometry(f'{int(w)}x{int(h)}+{int(x)}+{int(y)}')
def __init__(self, master): self.master = master self.font = Font(size=8)
from tkinter import * from tkinter.font import Font from PIL import ImageTk root = Tk() clock_date = Label(root) clock_date.pack() clock_time = Label(root) clock_time.pack() weather_frame = Frame(root) img, weather_info, exclude = "", [], "" start_time = time.time() font_size, font_color = 32, "#000000" font = Font(family="helvetica", size=font_size) bg_color, bg_trans, alpha = "#000000", False, 1 clock_run, weather_active = False, False clock_size_x, clock_size_y, weather_x, weather_y = 0, 0, 0, 0 home_city, lat, lon = "", 0, 0 url, api_key = "", "" class WeatherObject: def __init__(self, dt, temp, feels_like, icon, description, rain, snow): self.dt = dt self.date = self.convert_date()
def __init__(self, master): master.title("Log In") # icon win_width = 550 win_height = 500 swidth = master.winfo_screenwidth() sheight = master.winfo_screenheight() x = int((swidth / 2) - (win_width / 2)) y = int((sheight / 2) - (win_height / 2)) ## master.geometry("{}x{}+{}+{}".format(win_width, win_height, x, y)) master.geometry(f"{win_width}x{win_height}+{x}+{y}") master.resizable(0, 0) font1 = Font(weight="bold", size=10) # defining font font2 = Font(weight="bold", size=9) ttk.Style().configure("TNotebook.Tab", background="azure", font=('Times', '15', 'normal'), padding=(105, 10)) self.tabs = ttk.Notebook(master) self.tabs.grid(row=0, column=1, pady=(5, 0)) self.regisframe = Frame(self.tabs, bg="white") self.tabs.add(self.regisframe, text="Register") self.logframe = Frame(self.tabs, bg="white") self.tabs.add(self.logframe, text="Log In") # register------------- # content frame self.regcont = Frame(self.regisframe, relief="groove", borderwidth=2) self.regcont.grid(row=4, column=0, pady=60, padx=55) self.label = Label( self.regcont, text="Please enter the following details to register.", font=font1, fg="blue") self.label.grid(row=4, column=0, padx=10, pady=20, columnspan=2, sticky=W) # fullname self.uname = Label(self.regcont, text="Full Name:", font=font2) self.uname.grid(row=5, column=0, pady=10, padx=20, sticky=E) self.euname = ttk.Entry(self.regcont, width=30) self.euname.grid(row=5, column=1, padx=(0, 20), sticky=W) # e-mail self.mail = Label(self.regcont, text="E-Mail:", font=font2) self.mail.grid(row=7, column=0, pady=10, padx=20, sticky=E) self.enmail = ttk.Entry(self.regcont, width=30) self.enmail.grid(row=7, column=1, padx=(0, 20), sticky=W) # password self.pwd = Label(self.regcont, text="Password:"******"*", width=30) self.epass.grid(row=10, column=1, padx=(0, 20), sticky=W) # confirm password self.cpwd = Label(self.regcont, text="Confirm Password:"******"*", width=30) self.ecpass.grid(row=11, column=1, padx=(0, 30), sticky=W) self.labl = ttk.Label(self.regcont, text="By clicking on REGISTER you accept our") self.labl.grid(row=12, column=0, padx=(10, 0), pady=(10, 20)) # link self.link = Label(self.regcont, text="Terms and Conditions", fg="red", cursor="hand2") self.link.grid(row=12, column=1, pady=(10, 20), sticky=W) self.link.bind("<Button-1>", self.openlink) # button self.regbtn = ttk.Button(self.regcont, text="Register") self.regbtn.grid(column=1, row=13, pady=(0, 20), sticky=W) self.regbtn.bind("<Button-1>", self.registerdata) # login tab------------------------------------ # content frame self.logcont = Frame(self.logframe, relief="groove", borderwidth=2) self.logcont.grid(row=2, column=0, pady=120, padx=120) self.label = Label(self.logcont, text="Please enter your credentials to login.", font=font1, fg="blue") self.label.grid(row=3, column=0, padx=10, pady=20, columnspan=2) # username self.user = Label(self.logcont, text="Email:", font=font2) self.user.grid(row=4, column=0, pady=10, padx=20, sticky=E) self.euser = ttk.Entry(self.logcont, width=30) self.euser.grid(row=4, column=1, padx=(0, 20), sticky=W) # password self.pwd = Label(self.logcont, text="Password:"******"*", width=30) self.elpass.grid(row=5, column=1, padx=(0, 20), sticky=W) self.logbtn = ttk.Button(self.logcont, text="Log In") self.logbtn.grid(column=1, row=13, padx=20, pady=10, sticky=W) self.logbtn.bind("<Button-1>", self.getlogdata)
def create_widgets(self): icon_image_root = os.path.join(Application.APPLICATION_ROOT, 'image') self.toolbar = tk.Frame(self, bg="#eee") self.toolbar.pack(side="top", fill="x") # Menu definition self.options_btn = ttk.Menubutton(self.toolbar, text='〓') self.options_btn.menu = tk.Menu(self.options_btn, tearoff=0, background='white') self.options_btn["menu"] = self.options_btn.menu format_menu = tk.Menu(self.toolbar, tearoff=False, background='white') format_menu.add_checkbutton(label="Emphasize", variable=self.font_bold_enabled, command=self.enable_emphasize) format_menu.add_checkbutton(label="Wrap", variable=self.font_wrap_enabled, command=self.toggle_wrap) format_menu.add_command(label='Font', underline=0, command=self.choose_editor_font) color_menu = tk.Menu(self.toolbar, tearoff=False, background='white') color_menu.add_command(label='Background', underline=0, command=self.choose_editor_bgcolor) color_menu.add_command(label='Text Color', underline=0, command=self.choose_editor_fgcolor) format_menu.add_cascade(label='Color', underline=0, menu=color_menu) self.options_btn.menu.add_cascade(label='Format', underline=0, menu=format_menu) # Convert Menu convert_menu = tk.Menu(self.toolbar, tearoff=False, background='white') convert_menu.add_command(label='Canonicalize', underline=0, command=self.canonicalize_editor_data) self.options_btn.menu.add_cascade(label='Convert', underline=0, menu=convert_menu) self.options_btn.menu.add_command( label='Print', underline=0, command=lambda: self.command_parser.execute('print=this')) self.options_btn.menu.add_command(label='Save Profile', underline=0, command=self.save_profile) self.options_btn.menu.add_command(label='Exit', underline=0, command=self.on_delete_window) self.options_btn.pack(side="left") new_icon_path = os.path.join(icon_image_root, 'new.gif') new_icon = tk.PhotoImage(file=new_icon_path) self.new_btn = tk.Button(self.toolbar, image=new_icon, command=self.new) self.new_btn.image = new_icon self.new_btn.config(relief=tk.GROOVE) self.new_btn.bind('<Enter>', self.on_enter) self.new_btn.bind('<Leave>', self.on_leave) self.new_btn.pack(side="left") open_icon_path = os.path.join(icon_image_root, 'open.gif') open_icon = tk.PhotoImage(file=open_icon_path) self.read_btn = tk.Button(self.toolbar, image=open_icon, command=self.read) self.read_btn.image = open_icon self.read_btn.config(relief=tk.GROOVE) self.read_btn.bind('<Enter>', self.on_enter) self.read_btn.bind('<Leave>', self.on_leave) self.read_btn.pack(side="left") save_icon_path = os.path.join(icon_image_root, 'save.gif') save_icon = tk.PhotoImage(file=save_icon_path) self.save_btn = tk.Button(self.toolbar, image=save_icon, command=self.save) self.save_btn.image = save_icon self.save_btn.config(relief=tk.GROOVE) self.save_btn.bind('<Enter>', self.on_enter) self.save_btn.bind('<Leave>', self.on_leave) self.save_btn.pack(side="left") saveas_icon_path = os.path.join(icon_image_root, 'save_as.gif') save_as_icon = tk.PhotoImage(file=saveas_icon_path) self.save_as_btn = tk.Button(self.toolbar, image=save_as_icon, command=self.save_as) self.save_as_btn.image = save_as_icon self.save_as_btn.config(relief=tk.GROOVE) self.save_as_btn.bind('<Enter>', self.on_enter) self.save_as_btn.bind('<Leave>', self.on_leave) self.save_as_btn.pack(side="left") highlight_icon_path = os.path.join(icon_image_root, 'highlight.gif') highlight_icon = tk.PhotoImage(file=highlight_icon_path) self.highlight_btn = tk.Button(self.toolbar, image=highlight_icon, command=self.make_highlight) self.highlight_btn.image = highlight_icon self.highlight_btn.config(relief=tk.GROOVE) self.highlight_btn.bind('<Enter>', self.on_enter) self.highlight_btn.bind('<Leave>', self.on_leave) self.highlight_btn.pack(side="left") clear_icon_path = os.path.join(icon_image_root, 'clear.gif') clear_icon = tk.PhotoImage(file=clear_icon_path) self.clear_btn = tk.Button(self.toolbar, image=clear_icon, command=self.clear) self.clear_btn.image = clear_icon self.clear_btn.config(relief=tk.GROOVE) self.clear_btn.bind('<Enter>', self.on_enter) self.clear_btn.bind('<Leave>', self.on_leave) self.clear_btn.pack(side="left") search_icon_path = os.path.join(icon_image_root, 'search.gif') search_icon = tk.PhotoImage(file=search_icon_path) self.searrch_btn = tk.Button(self.toolbar, image=search_icon, command=self.search) self.searrch_btn.image = search_icon self.searrch_btn.config(relief=tk.GROOVE) self.searrch_btn.bind('<Enter>', self.on_enter) self.searrch_btn.bind('<Leave>', self.on_leave) self.searrch_btn.pack(side="left") popout_icon_path = os.path.join(icon_image_root, 'popout.gif') popout_icon = tk.PhotoImage(file=popout_icon_path) self.popout_btn = tk.Button(self.toolbar, image=popout_icon, command=self.pop_out) self.popout_btn.image = popout_icon self.popout_btn.config(relief=tk.GROOVE) self.popout_btn.bind('<Enter>', self.on_enter) self.popout_btn.bind('<Leave>', self.on_leave) self.popout_btn.pack(side="left") # Command box self.command_label = tk.Label(self.toolbar, text=' >') self.command_label.pack(side='left') self.command_box = tk.Entry(self.toolbar, textvariable=self.command_var) self.command_box.config(bg='#CCDDFF') self.command_box.config(fg='#771133') self.command_box.bind('<Return>', self.command_issue) self.command_box.config(relief=tk.GROOVE) self.command_box.pack(side='left', ipady=0.01) command_issue_icon_path = os.path.join(icon_image_root, 'command_issue.gif') command_issue_icon = tk.PhotoImage(file=command_issue_icon_path) self.command_issue_btn = tk.Button(self.toolbar, image=command_issue_icon, command=self.command_issue) self.command_issue_btn.image = command_issue_icon self.command_issue_btn.config(relief=tk.GROOVE) self.command_issue_btn.bind('<Enter>', self.on_enter) self.command_issue_btn.bind('<Leave>', self.on_leave) self.command_issue_btn.pack(side="left") close_icon_path = os.path.join(icon_image_root, 'close.gif') close_icon = tk.PhotoImage(file=close_icon_path) self.close_btn = tk.Button(self.toolbar, image=close_icon, command=self.close) self.close_btn.image = close_icon self.close_btn.config(relief=tk.FLAT) self.close_btn.bind('<Enter>', self.on_enter_close) self.close_btn.bind('<Leave>', self.on_leave_close) self.close_btn.pack(side="right") # Creates a bold font self.bold_font = Font(family="Helvetica", size=14, weight="bold") # Notebook definition self.notebook = ttk.Notebook(self, width=self.master.winfo_screenwidth()) self.notebook.pack(fill='both', expand=True)
def __init__(self, canvas, drs, **attribs): self._drs = drs self._canvas = canvas canvas.font = Font(font=canvas.itemcget(canvas.create_text(0, 0, text=''), 'font')) canvas._BUFFER = 3 self.bbox = (0, 0, 0, 0)
def insert(event): global start val = int(node.get()) btree.insertnode(val, start) start += 2 def delete(event): k = node.get() print(k) window = tk.Tk(className="Binary Tree") window.configure(bg='#ffffff') primary_fonts = Font(family='Consolas', size=14, weight='normal') secondary_fonts = Font(family='Consolas', size=12, weight='normal') bold_fonts = Font(family='Consolas', size=12, weight='bold') #setting_Size window_w = window.winfo_screenwidth() // 2 window_h = window.winfo_screenheight() * 3 // 4 size = str(window_w) + "x" + str(window_h) window.geometry(size) window.resizable(0, 0) heading = tk.Label(text="Binary Tree") heading.configure(font=primary_fonts, bg='#ffffff') heading.pack(fill=tk.X) definition = tk.Label(
vm = StringVar() v7 = StringVar() v8 = StringVar() v9 = StringVar() vml = StringVar() vz = StringVar() vdz = StringVar() veq = StringVar() vd = StringVar() vl.set("Value") l = Label(a, textvariable=vl, fg="blue", bg="#A8E1F8", bd=3, width=20) l.grid(row=1, column=1) t1 = Entry(a, textvariable=v, bd=5, cursor="arrow", relief="raised", width=45) t1.grid(row=1, column=2, columnspan=4) text = Text(a) mfnt = Font(family="Times New Roman", size=8, weight="bold") text.configure(font=mfnt) v1.set("1") def one(): t1.insert(END, "1") b1 = Button(a, text="1", fg="black", font=mfnt, activebackground="cyan", bd=7, relief="raised",
def createWidgets(self): self.top = self.winfo_toplevel() self.style = Style() self.Check2Var = IntVar(value=0) self.style.configure('TCheck2.TCheckbutton', font=('微软雅黑',9,'bold')) self.Check2 = Checkbutton(self.top, text='题号', variable=self.Check2Var, style='TCheck2.TCheckbutton') self.Check2.place(relx=0.388, rely=0.705, relwidth=0.125, relheight=0.039) self.Check1Var = IntVar(value=0) self.style.configure('TCheck1.TCheckbutton', font=('微软雅黑',9,'bold')) self.Check1 = Checkbutton(self.top, text='打乱顺序', variable=self.Check1Var, style='TCheck1.TCheckbutton') self.Check1.place(relx=0.122, rely=0.705, relwidth=0.247, relheight=0.039) self.Command1Var = StringVar(value='出题') self.style.configure('TCommand1.TButton', font=('微软雅黑',9,'bold')) self.Command1 = Button(self.top, text='出题', textvariable=self.Command1Var, command=self.Command1_Cmd, style='TCommand1.TButton') self.Command1.place(relx=0.082, rely=0.798, relwidth=0.839, relheight=0.114) self.topRadioVar = StringVar() self.style.configure('TOption3.TRadiobutton', font=('微软雅黑',9,'bold')) self.Option3 = Radiobutton(self.top, text='随机挖空', value='Option3', variable=self.topRadioVar, style='TOption3.TRadiobutton') self.Option3.place(relx=0.653, rely=0.557, relwidth=0.247, relheight=0.046) self.style.configure('TOption2.TRadiobutton', font=('微软雅黑',9,'bold')) self.Option2 = Radiobutton(self.top, text='挖空下联', value='Option2', variable=self.topRadioVar, style='TOption2.TRadiobutton') self.Option2.place(relx=0.388, rely=0.557, relwidth=0.247, relheight=0.046) self.style.configure('TOption1.TRadiobutton', font=('微软雅黑',9,'bold')) self.Option1 = Radiobutton(self.top, text='挖空上联', value='Option1', variable=self.topRadioVar, style='TOption1.TRadiobutton') self.Option1.place(relx=0.122, rely=0.557, relwidth=0.247, relheight=0.046) self.Combo1List = ['七年级上册', '七年级下册', '八年级上册', '八年级下册'] self.Combo1Var = StringVar(value='请在此选择预置诗题') self.Combo1 = Combobox(self.top, textvariable=self.Combo1Var, values=self.Combo1List, font=('微软雅黑', 9, 'bold')) self.Combo1.bind('<<ComboboxSelected>>', self.Add_Listbox_Cmd) self.Combo1.place(relx=0.122, rely=0.093, relwidth=0.798) self.Label2Var = StringVar(value='请选择出题方式:') self.style.configure('TLabel2.TLabel', anchor='w', font=('微软雅黑',9,'bold')) self.Label2 = Label(self.top, textvariable=self.Label2Var, style='TLabel2.TLabel') self.Label2.place(relx=0.082, rely=0.483, relwidth=0.245, relheight=0.039) self.Lable1Var = StringVar(value='请选择年段等级:') self.style.configure('TLable1.TLabel', anchor='w', font=('微软雅黑',9,'bold')) self.Lable1 = Label(self.top, textvariable=self.Lable1Var, style='TLable1.TLabel') self.Lable1.place(relx=0.082, rely=0.037, relwidth=0.245, relheight=0.039) self.Label3Var = StringVar(value='附加选项:') self.style.configure('TLabel1.TLabel', anchor='w', font=('微软雅黑',9,'bold')) self.Label1 = Label(self.top, textvariable=self.Label3Var, style='TLabel1.TLabel') self.Label1.place(relx=0.082, rely=0.631, relwidth=0.153, relheight=0.039) self.Check3Var = IntVar(value=0) self.style.configure('TCheck3.TCheckbutton', font=('微软雅黑',9,'bold')) self.Check3 = Checkbutton(self.top, text='附加作者和诗题', variable=self.Check3Var, style='TCheck3.TCheckbutton') self.Check3.place(relx=0.653, rely=0.705, relwidth=0.268, relheight=0.046) self.PoemsList = [] self.PoemsListBoxFont = Font(font=('微软雅黑', 9)) self.PoemsListBox = Listbox(self.top, font=self.PoemsListBoxFont, selectmode=MULTIPLE) # for each in self.PoemsList: # self.PoemsListBox.insert(END, each) self.PoemsListBox.place(relx=0.122, rely=0.167, relwidth=0.798, relheight=0.288)