def __init__(self, master): self.predictor = predictor() self.master = master master.title("A simple GUI") master.geometry('355x355') self.main_label = Label(master, text="Simple Credit Card Default Evaluation") self.main_label.pack() self.topFrame = Frame(master) self.topFrame.pack() self.botFrame = Frame(master) self.botFrame.pack(side=BOTTOM) self.input_label = [] self.input_label_text = [ "Balance Limit", "Gender", "Education", "Marriage", "Age", "Missed payment", "Amount Owed" ] self.input_component = [] self.input_component_text = [ ["None", "1 - 100,000", "100,001 - 500,000", "500,001 and more"], ["Male", "Female"], ["Graduate school", "University", "High school", "Others"], ["Married", "Single", "Others"], [ "1-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80 and more" ], ["None", "1", "2", "3", "4 and more"], ["None", "Low", "Medium", "High"] ] self.input_value = [] for i in range(0, 7): temp_label = Label(self.topFrame, text=self.input_label_text[i], width=15) self.input_label.append(temp_label) temp_label.grid(row=i, column=0) temp_value = StringVar() self.input_value.append(temp_value) temp_input_component = Combobox(self.topFrame, textvariable=temp_value, width=15) self.input_component.append(temp_input_component) temp_input_component.grid(row=i, column=1) temp_input_component["values"] = self.input_component_text[i] temp_input_component.current(0) self.prediction_text = 'Select each group you belong to' self.prediction_label = Label(self.botFrame, text=self.prediction_text) self.prediction_label.pack() self.greet_button = Button(self.botFrame, text="Predict", command=self.predict) self.greet_button.pack(side=LEFT) self.close_button = Button(self.botFrame, text="Close", command=master.quit) self.close_button.pack(side=RIGHT)
def __init__(self, master): '''The init is where the phsysical layout of the GUI is. Has all the labels,textboxes, buttons, and entry-points All the buttons have commands attached to them that are called.''' self.master = master master.title("CSCI Final Project") self.file = None self.fileL = [] self.filtL = [] self.prediction = None self.master.minsize(width=350, height=700) self.author = None self.genre = None self.year = None self.entered_file = '' self.statMethod = 0 self.skGenre = None self.skYear = None self.skTop = None self.skBottom = None self.idGenre = None self.idYear = None self.idTop = None self.idBottom = None # message Label Text Stuff self.workingLabel = Label(master, text="File to Edit: ") # Entry box storage section vcmd = master.register(self.validate) vcmd2 = master.register(self.validateGenre) vcmd3 = master.register(self.validateYear) vcmd4 = master.register(self.validateAuthor) self.entry = Entry(master, validate="key", validatecommand=(vcmd, '%P')) # Buttons and input boxes declaration self.add_document = Button(master, text="Add Document", command=lambda: self.update("add")) self.label1 = Label(master, text="Document Name: ") self.fileEntry = Entry(master, validate='key', validatecommand=(vcmd, '%P'), bd=3) self.filter0 = Button(master, text="Normalize White Space", command=lambda: self.applyFilter("nw")) self.filter1 = Button(master, text="Normalize Case", command=lambda: self.applyFilter("nc")) self.filter2 = Button(master, text="Strip Null", command=lambda: self.applyFilter("sn")) self.filter3 = Button(master, text="Strip Numbers", command=lambda: self.applyFilter("snum")) self.filter4 = Button(master, text="Strip Common Words", command=lambda: self.applyFilter("common")) self.appFilter = Button( master, text="APPLY FILTERS", command=lambda: self.applyFilter("apply filters")) self.addInfo = Label(master, text="-----------Add Info--------------") self.addInfo.grid(row=3, column=1, stick=W + E) self.GenreButt = Label(master, text='Enter Genre: ') self.GenreEnt = Entry(master, validate='key', validatecommand=(vcmd2, '%P'), bd=3) self.YearButt = Label(master, text='Enter Year: ') self.YearEnt = Entry(master, validate='key', validatecommand=(vcmd3, '%P'), bd=3) self.AuthorButt = Label(master, text='Enter Author: ') self.AuthorEnt = Entry(master, validate='key', validatecommand=(vcmd4, '%P'), bd=3) self.filtlab = Label(master, text="------------Filters------------") self.filtlab.grid(row=7, column=1) self.trainsection = Label(master, text="--------Training----------") self.trainsection.grid(row=14, column=1, stick=W + E) self.statmethod1 = Button(master, text="Sk Tree Genre", command=lambda: self.chooseStat('1')) self.statmethod2 = Button(master, text="Sk Tree Year", command=lambda: self.chooseStat('2')) self.statmethod3 = Button(master, text="ID3 Genre", command=lambda: self.chooseStat('3')) self.statmethod4 = Button(master, text="ID3 Year ", command=lambda: self.chooseStat('4')) self.statmethod5 = Button(master, text="SK Top Words", command=lambda: self.chooseStat('5')) self.statmethod6 = Button(master, text="SK Bottom Words", command=lambda: self.chooseStat('6')) self.statmethod7 = Button(master, text="ID3 Top Words", command=lambda: self.chooseStat('7')) self.statmethod8 = Button(master, text="ID3 Bottom Words", command=lambda: self.chooseStat('8')) self.statmethod9 = Button(master, text="SK PCA", command=lambda: self.chooseStat('9')) self.trainButton = Button(master, text="TRAIN", command=lambda: self.training(), bd=3) self.PredictButton = Button(master, text="Predict Document", bd=5, command=lambda: self.predict()) self.predictEntry = Entry(master) self.master.bind('<Return>', lambda event: self.update("enter")) #Layout and grid self.label1.grid(row=1, column=0, columnspan=2, stick=W + E) self.fileEntry.grid(row=1, column=2, columnspan=2, stick=W + E) self.add_document.grid(row=6, column=3, stick=W + E) self.filter0.grid(row=8, column=1, stick=W + E) self.filter1.grid(row=9, column=1, stick=W + E) self.filter2.grid(row=10, column=1, stick=W + E) self.filter3.grid(row=11, column=1, stick=W + E) self.filter4.grid(row=12, column=1, stick=W + E) self.appFilter.grid(row=13, column=1, stick=W + E) self.GenreButt.grid(row=4, column=1, stick=W + E) self.GenreEnt.grid(row=4, column=2, stick=W + E) self.AuthorButt.grid(row=5, column=1, stick=W + E) self.AuthorEnt.grid(row=5, column=2, stick=W + E) self.YearButt.grid(row=6, column=1, stick=W + E) self.YearEnt.grid(row=6, column=2, stick=W + E) self.statmethod1.grid(row=15, column=1, stick=W + E) self.statmethod2.grid(row=15, column=2, stick=W + E) self.statmethod3.grid(row=16, column=1, stick=W + E) self.statmethod4.grid(row=16, column=2, stick=W + E) self.statmethod5.grid(row=17, column=1, stick=W + E) self.statmethod6.grid(row=17, column=2, stick=W + E) self.statmethod7.grid(row=18, column=1, stick=W + E) self.statmethod8.grid(row=18, column=2, stick=W + E) self.statmethod9.grid(row=19, column=1, stick=W + E) self.trainButton.grid(row=19, column=2, stick=W + E) self.predictgenrelabel = Label(master, text="Genre of Predicted: ") self.predictfileLabel = Label(master, text="File to Predicted: ") self.predictyearLabel = Label(master, text="Year of Predict: ") self.predictfileEntry = Entry(master, validate='key', validatecommand=(vcmd, '%P')) self.predictgenreEntry = Entry(master, validate='key', validatecommand=(vcmd2, '%P')) self.predictyearEntry = Entry(master, validate='key', validatecommand=(vcmd3, '%P'), bd=3) self.predictgenrelabel.grid(row=20, column=2, stick=W + E) self.predictfileLabel.grid(row=20, column=1, stick=W + E) self.predictfileEntry.grid(row=21, column=1, stick=W + E) self.predictgenreEntry.grid(row=21, column=2, stick=W + E) self.predictyearLabel.grid(row=20, column=3, stick=W + E) self.PredictButton.grid(row=22, column=1, stick=W + E) self.predictyearEntry.grid(row=21, column=3, stick=W + E) self.Documents = Label( master, text="Title Genre Author Year" ) self.Documents.grid(row=24, column=1) self.text = Text(master) self.text.grid(row=25, column=1)
def __init__(self, window): self.window = window self.window.wm_title("BookStore") l1 = Label(window, text="Title") l1.grid(row=0, column=0) l2 = Label(window, text="Author") l2.grid(row=0, column=2) l3 = Label(window, text="Year") l3.grid(row=1, column=0) l4 = Label(window, text="ISBN") l4.grid(row=1, column=2) self.title_text = StringVar() self.e1 = Entry(window, textvariable=self.title_text) self.e1.grid(row=0, column=1) self.author_text = StringVar() self.e2 = Entry(window, textvariable=self.author_text) self.e2.grid(row=0, column=3) self.year_text = StringVar() self.e3 = Entry(window, textvariable=self.year_text) self.e3.grid(row=1, column=1) self.isbn_text = StringVar() self.e4 = Entry(window, textvariable=self.isbn_text) self.e4.grid(row=1, column=3) self.list1 = Listbox(window, height=6, width=35) self.list1.grid(row=2, column=0, rowspan=6, columnspan=2) sb1 = Scrollbar(window) sb1.grid(row=2, column=2, rowspan=6) self.list1.configure(yscrollcommand=sb1.set) sb1.configure(command=self.list1.yview) self.list1.bind('<<ListboxSelect>>', self.get_selected_row) b1 = Button(window, text="View all", width=12, command=self.view_command) b1.grid(row=2, column=3) b2 = Button(window, text="Search entry", width=12, command=self.search_command) b2.grid(row=3, column=3) b3 = Button(window, text="Add entry", width=12, command=self.add_command) b3.grid(row=4, column=3) b4 = Button(window, text="Update selected", width=12, command=self.update_command) b4.grid(row=5, column=3) b5 = Button(window, text="Delete selected", width=12, command=self.delete_command) b5.grid(row=6, column=3) b6 = Button(window, text="Close", width=12, command=self.window.destroy) b6.grid(row=7, column=3)
def __init__(self, configobj): self.window = Toplevel() # self.window.option_add("*Background", "white") self.window.protocol('WM_DELETE_WINDOW', self.cancel) f0 = Frame(self.window) f0.pack(side='top', anchor='w', expand=False, fill='x') t = _( 'Note that most changes become effective only after restarting the program.' ) text = Text(f0, height=len(t) // 80 + 1, width=80, wrap='word') text.insert(1.0, _(t)) text.config(state='disabled') text.pack(side='left', expand=True, fill='x') Button(f0, text=_('Save'), command=self.save, bg='lightgreen').pack(side='right', anchor='e') Button(f0, text=_('Cancel'), command=self.cancel, bg='orange').pack(side='right', anchor='e') self.configobj = configobj self.variables = { } # will store the Tkinter variables containing the values special_values = [ '# -----', '# section', '# label', '# editable', '# values', ] sf = ScrolledFrame(self.window, usehullsize=1, hull_height=500) sf.pack(side='top', anchor='w', expand=True, fill='both') f = sf.interior() ctr = -1 for prop in configobj['options']: comments = configobj['options'].comments[prop] # new "section"? sec = self.retrieve('# section:', comments) if sec: ctr += 1 Label(f, text=_(sec), justify='left', bg='#eeeeee', font=('Helvetica', 14, 'bold')).grid(row=ctr, column=0, columnspan=3, sticky='we', pady=10) if '# editable' in comments: ctr += 1 label = self.retrieve('# label:', comments) or prop label = label.strip() values = self.retrieve('# values:', comments) if values: values = values.split(', ') else: values = [] help_text = ' '.join( x[1:].strip() for x in comments if not any(x.startswith(v) for v in special_values)).strip() if 'BOOLEAN' in values: self.variables[prop] = BooleanVar() else: self.variables[prop] = StringVar() if '--' in values and configobj['options'][prop] == '': self.variables[prop].set('--') else: self.variables[prop].set(configobj['options'][prop]) if 'BOOLEAN' in values: Checkbutton(f, text=_(label), indicatoron=1, variable=self.variables[prop]).grid( row=ctr, column=1, sticky='nw', pady=5) elif values and not 'INT' in values: Label(f, text=_(label), justify='left').grid(row=ctr, column=0, sticky='nw', pady=5) Combobox( f, justify='left', textvariable=self.variables[prop], values=values, ).grid(row=ctr, column=1, sticky='nw', pady=5) else: Label(f, text=_(label), justify='left').grid(row=ctr, column=0, sticky='nw', pady=5) Entry(f, width=20, textvariable=self.variables[prop]).grid(row=ctr, column=1, sticky='nw', pady=5) if help_text: ht = _(help_text) text = Text(f, height=len(ht) // 60 + 1, width=60, borderwidth=0, wrap='word') text.insert(1.0, _(help_text)) text.config(state='disabled') text.grid(row=ctr, column=2, sticky='nsew', pady=5) self.window.update_idletasks() self.window.focus() self.window.grab_set() self.window.wait_window()
panelB = Label(image=img_head) panelB.image = img_head panelB.pack(side="right") def save_file(): global file_path # img_save file_path = tkinter.filedialog.asksaveasfilename(title="保存图片", filetypes=[("PNG", ".png") ]) if file_path is not None: # print(file_path) imwrite(file_path + ".png", img_save) window = Tk(screenName="国旗+头像") panelA = None panelB = None btn2 = Button(window, text="保存图像", command=save_file) btn2.pack(side="bottom") btn1 = Button(window, text="选择图像", command=deal_flag) btn1.pack(side="bottom") l = Label(text="QQ:1030635594") l.pack() window.mainloop()
WIN_WIDTH = 680 WIN_HEIGHT = 620 FONT_NAME = 'Courier New' FONT_SIZE = 14 DEFAULT_MODEL_LIST = get_files_from_root('./models', '.sav') DEFAULT_FILE_LIST = get_files_from_root('./data', '.csv') LBL_DEFAULT_TEXT = 'Choose file and model and press "Scan"' window = Tk() lbl = Label(window, text=LBL_DEFAULT_TEXT, font=(FONT_NAME, FONT_SIZE)) lbl_records_count = Label(window, text='Number of records:', font=(FONT_NAME, FONT_SIZE)) btn_scan = Button(window, width=8, text='Scan', font=(FONT_NAME, FONT_SIZE), bg='#3333ff', fg='#ffffff') btn_clear = Button(window, width=8, text='Clear', font=(FONT_NAME, FONT_SIZE), bg='#3f3f3f', fg='#ffffff') model_list = Combobox(window) file_list = Combobox(window) records_count = Entry(window, width=15) result_text_field = scrolledtext.ScrolledText(window, width=65, height=35, font=(FONT_NAME, 12))
new_vehicle_expiry = Entry(editframe) def delete_button_func(): """ delete item from database """ result = delete_item(new_vehicle_license.get()) if result is not None: show_info(result) delete_button = Button(editframe, command=delete_button_func, text="Delete", background=btn_colour, disabledforeground="DeepSkyBlue4", borderwidth=0, highlightbackground=bg_alt) delete_img = PhotoImage( file="assets/buttons/button_delete.gif") # make sure to add "/" not "\" delete_button.config(image=delete_img) delete_button.pack() def quit_edit(): new_vehicle_license1 = add_new(new_vehicle_license.get(), new_vehicle_expiry.get()) if new_vehicle_license1 is not None: show_info(new_vehicle_license1)
def loadInfo(workbookPath): typeOfManifest = [-1] skip = [0] startAt = [""] top = Tk() L1 = Label( top, text= "Please select which container to start at or \n how many containers to skip as well as\n whether to do PARS, A8As, or both \n " ) L1.config(font=("Courier", 16)) L1.grid(row=0, column=0, columnspan=5) L2 = Label(top, text="Start at container #:") L2.config(font=("Courier", 10)) L2.grid(row=1, column=0, columnspan=2) E1 = Entry(top, bd=5, width=39) E1.grid(row=1, column=2, columnspan=2) L3 = Label(top, text="OR") L3.grid(row=2, column=1, columnspan=2) L3.config(font=("Courier", 20)) L4 = Label(top, text="# of containers to skip:") L4.grid(row=3, column=0, columnspan=2) L4.config(font=("Courier", 10)) E2 = Entry(top, bd=5, width=39) E2.grid(row=3, column=2, columnspan=2) E2.insert(0, "0") top.lift() top.attributes('-topmost', True) top.after_idle(top.attributes, '-topmost', False) def callbackType(typeOf): startAt[0] = E1.get().strip() skip[0] = E2.get().strip() typeOfManifest[0] = typeOf top.destroy() MyButton5 = Button(top, text="PARS", command=lambda: callbackType(0), width=10) MyButton5.grid(row=4, column=0) MyButton5.config(font=("Courier", 16)) MyButton6 = Button(top, text="A8A", command=lambda: callbackType(1), width=10) MyButton6.grid(row=4, column=1) MyButton6.config(font=("Courier", 16)) MyButton7 = Button(top, text="BOTH", command=lambda: callbackType(2), width=10) MyButton7.grid(row=4, column=2) MyButton7.config(font=("Courier", 16)) w = 620 # width for the Tk root h = 260 # height for the Tk root # get screen width and height ws = top.winfo_screenwidth() # width of the screen hs = top.winfo_screenheight() # height of the screen # calculate x and y coordinates for the Tk root window x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) # set the dimensions of the screen # and where it is placed top.geometry('%dx%d+%d+%d' % (w, h, x, y)) top.mainloop() routing = load_workbook(workbookPath) routing = routing.get_active_sheet() pars = [] a8a = [] colDict = { CONTAINERNUMBER: "", BOOKING: "", VESSEL: "", # WEIGHLBS: "", WEIGHT: "", PIECES: "", SIZE: "", PARS: "", HAZ: "" } for cell in next(routing.rows): for contProperty in colDict: if contProperty in cell.value: colDict[contProperty] = cell.col_idx - 1 i = 0 found = startAt[0] == "" containerList = [""] for row in routing.rows: if i > int(skip[0]): container = Container() for contProperty in container.properties: # if contProperty != WEIGHLBS: container.properties[contProperty] = str( row[colDict[contProperty]].value) if found or container.properties[CONTAINERNUMBER] == startAt[0]: if not container.properties[CONTAINERNUMBER] in containerList: found = True if container.properties[PARS] == 'PARS': pars.append(container) elif container.properties[PARS] == 'A8A': a8a.append(container) containerList.append(container.properties[CONTAINERNUMBER]) # print(container.properties[CONTAINERNUMBER]) i += 1 return (pars, a8a, typeOfManifest)
from tkinter import Tk, IntVar, Checkbutton, Button, W def print_button_callback(): global state for i in range(3): if state[i][1].get(): print(state[i][0]) myApp=Tk() state = [("Option {0}".format(i+1),IntVar()) for i in range(3)] for i in range(3): Checkbutton(myApp, text=state[i][0], variable=state[i][1]).grid(row=i, sticky=W) Button(myApp, text="Print", command=print_button_callback).grid(row=3, sticky=W) myApp.mainloop()
def __init__(self, parent, controller): Frame.__init__(self, parent) label = Label(self, text="Analyse time series using arima model") label.pack(anchor="n", padx=10, pady=10) self.GraphDrawn = False """ fuction which plots graph and makes a figure then packing it """ def plot_graph(dt): lf = ttk.Labelframe(self, text='Plot Area') lf.pack() headers = ['date', 'values'] f = Figure(figsize=(5, 4), dpi=100) ax1 = f.add_subplot(111) dt.plot(legend=True, ax=ax1) canvas = FigureCanvasTkAgg(f, self) self.GraphDrawn = True canvas.draw() canvas.get_tk_widget().pack(anchor="center", expand=True) toolbar = NavigationToolbar2Tk(canvas, self) canvas._tkcanvas.pack(anchor="center") self.GraphDrawn = True def parser(x): try: return datetime.strptime( x, '%Y-%m-%d' ) ## Attempts to read the data given by using the format yyyy/mm/dd except: return datetime.strptime( x, '%Y-%m' ) ## Attempts to read the data given by using the format yyyy/mm def forecast(fileAddress): if self.GraphDrawn == False: messagebox.showinfo( "Time Series Analysis", "This will take a minute please wait. A file will be output with the prediction on the same location as the program." ) series = pd.read_csv(fileAddress, header=0, parse_dates=[0], index_col=0, squeeze=True, date_parser=parser, skiprows=1) X = series.values size = int( len(X) * 0.6 ) ## sets the amount of data that is going to be tested (max would be 0.1 min would be 0.9) train, test = X[0:size], X[size:len( X )] ## defines the test data and the data which it will be compared to history = [x for x in train] predictions = list( ) ### defines a list for which the forecast will be input to for t in range(len(test)): model = ARIMA(history, order=( 5, 1, 0)) ## Runs arima algorithm in order make the model model_fit = model.fit(disp=0) ## Fits the model output = model_fit.forecast( ) ## Forecasts based on previous data within the window defined by arima yhat = output[0] predictions.append(yhat) obs = test[t] history.append(obs) """ Part of the function which makes a new data fram with the predictions and plots said data frame """ error = mean_squared_error(test, predictions) PredicVals = [] for i in range(int(len(predictions))): PredicVals.append( predictions[i].item() ) ##Due to the output of the forecast function being a numpy array in oder for me to plot the graph i have to add them to a list and get the modulous of them headers = ['date', 'values'] RowsNeedSkip = 1 + int( len(train) ) ##This is to remove the data which is unused for testing dt = read_csv( fileAddress, header=0, names=headers, skiprows=RowsNeedSkip ) #### Imports csv file again but having removed unneeded data dt.insert(2, "Predictions", PredicVals, True) ## inserts data which is needed dt.date = pd.to_datetime( dt.date ) ### Turns the date header into actual datetime data type values dt.set_index('date', inplace=True) dt.to_csv( 'prediction.csv' ) ### This will save a csv file with the actual and predicted values for the dates plot_graph(dt) elif self.GraphDrawn == True: pass self.opButton = Button( self, text="Time series forecasting using a csv file", command=lambda: forecast(controller.fileAddress)) self.opButton.pack(anchor="n") self.HomeButton = Button( self, text="Back to menu", command=lambda: controller.show_frame(MainMenu)) self.HomeButton.pack(anchor="s") self.ChangeFile = Button( self, text="Select/Change input file", command=lambda: controller.Unpack_ShowFrame(FileSelection)) self.ChangeFile.pack(anchor="s") self.exitbutton = Button(self, text="exit", command=lambda: exit()) self.exitbutton.pack(anchor="s")
def __init__(self, parent): self.parent = parent parent.title("Set") parent.iconbitmap("assets/cardsIcon.ico") #parent.config(bg="#384d9c") ################### Instance Variables ################### self.numbers = {1: "one", 2: "two", 3: "three"} self.colors = {"r": "red", "g": "green", "p": "purple"} self.shadings = {"e": "non", "h": "half", "f": "fully"} self.shapes = {"S": "squiggle", "D": "diamond", "O": "oval"} self.deck = [ Card(w, x, y, z) for w in self.numbers for x in self.colors for y in self.shadings for z in self.shapes ] # field is defined at the bottom since it requires the tk frame it's in self.helds = set() self.justDealt = False self.solutions = [] self.puzField = [] self.puzSols = [] self.score = 0 self.setsOnBoard = 0 self.gameState = 0 #0 is no game currently being played, 1 is solitaire, 2 is puzzle self.startTime = 0 self.imgDict = { str(w) + x + y + z: PhotoImage(file="assets/" + str(w) + x + y + z + ".png") for w in self.numbers for x in self.colors for y in self.shadings for z in self.shapes } self.empty = PhotoImage(file="assets/empty.png") ########################## GUI ########################## self.gameFrame = Frame(parent) self.fieldFrame = LabelFrame(self.gameFrame, text="") # the foundSets LabelFrame for puzzle mode will also go here self.lowerFrame = Frame(parent) self.foundSets = LabelFrame(self.lowerFrame, text="Sets Found") self.messageFrame = Frame(self.lowerFrame) self.message = Label(self.messageFrame, text="") self.msgUpdate = self.messageFrame.after(1, self.resetMessage, "") self.scoreboard = Label(self.lowerFrame, text="") self.deckStatus = Label(self.lowerFrame, text="") self.solsButton = Button(self.lowerFrame, text="Show current solutions.", command=self.showSolutions) self.field = [[ Spot( i, j, None, Button(self.fieldFrame, image=self.empty, bg="white", command=lambda i=i, j=j: self.bClick(i, j))) for j in range(7) ] for i in range(3)] #This is the game board, 21 spots max. A set is unavoidable with 20 spots. It is redefined in the startSolit method. #For puzzle mode the field will have only 4 columns and a seperate widget showing the found sets will be gridded into the fieldFrame ___TODO____ self.solitButton = Button(self.lowerFrame, text="Start/Restart a Solitaire Game", command=lambda: solit.start(self)) self.puzzleButton = Button(self.lowerFrame, text="Start/Restart a Puzzle Game", command=lambda: puz.start(self)) self.gameFrame.pack() self.fieldFrame.grid(row=0, column=0, padx=40) #.grid(row=0, column=0) for y in range( 3 ): #grid 12 of the 21 possible field buttons, additional buttons will get gridded in only if they have a card for x in range(4): self.field[y][x].button.grid(row=y, column=x) self.lowerFrame.pack() self.messageFrame.pack() self.message.pack() self.scoreboard.pack() self.deckStatus.pack() self.solsButton.pack() self.solitButton.pack() self.puzzleButton.pack(pady=(0, 40))
def __init__(self, parent, controller): Frame.__init__(self, parent) label = Label(self, text="Plotting time series with rolling mean") label.pack(anchor="n", padx=10, pady=10) self.GraphDrawn = False def plot_graph(fileAddress): lf = ttk.Labelframe(self, text='Plot Area') ### Adds plot area label lf.pack() headers = [ 'date', 'values' ] ### Created a list of the name of the headers which will serve as the axis labels dt = pd.read_csv(fileAddress, header=0, names=headers, skiprows=1) dt.date = pd.to_datetime( dt.date ) ### Turns the date header into actual datetime data type values dt.set_index('date', inplace=True) f = Figure( figsize=(5, 5), dpi=100) ### defines a figure in which to embed the graph ax1 = f.add_subplot(111) ### adds a subplot dt.rolling(12).mean().plot( legend=True, ax=ax1) ## Plot the data using rolling mean method canvas = FigureCanvasTkAgg( f, self ) ## Defines a canvas which can have a matploblib plot on it canvas.draw() ##Makes the canvas canvas.get_tk_widget().pack( anchor="center", expand=True) ### Adds the canvas to the frame toolbar = NavigationToolbar2Tk(canvas, self) ## Defines toolbar to be used canvas._tkcanvas.pack(anchor="center", expand=True) self.GraphDrawn == True if self.GraphDrawn == False: self.GraphDrawn = True ###Only allows user to plot graph if it has not yet been plotted for this frame elif self.GraphDrawn == True: canvas.get_tk_widget().destroy() toolbar.destroy() self.previewButton = Button( self, text=("Preview"), command=lambda: plot_graph(controller.fileAddress)) self.previewButton.pack(anchor="s", pady=1) self.ChangeFile = Button( self, text="Select/Change input file", command=lambda: controller.show_frame(FileSelection)) self.ChangeFile.pack(anchor="s", pady=1) self.HomeButton = Button( self, text="Back to menu", command=lambda: controller.show_frame(MainMenu)) self.HomeButton.pack(anchor="s", pady=1) self.exitbutton = Button(self, text="exit", command=lambda: exit()) self.exitbutton.pack(anchor="s", pady=1)
def __init__(self, mainwindow, project, material_study_to_edit): tk.Toplevel.__init__(self, mainwindow) self.mainwindow = mainwindow self.title('Material Study Creation Window') self.width = self.winfo_width() self.height = self.winfo_height() self.material_study = material_study_to_edit self.main_frame = tk.Frame(self) self.main_frame.pack(expand=True, fill='both') self.project = project if self.material_study is None: self.edit = False else: self.edit = True if project.hostcellid == '': self.mainwindow.printerror( 'Current project has no host cell! Please declare the perfect cell as host before creating any Material Study.' ) items = [ defstud.treetitle for defstud in list(self.project.defect_studies.values()) ] if self.material_study is not None: label_on = self.material_study.treetitle + ' Defect Studies' items_on = [ defect_study.treetitle for defect_study in list( self.material_study.defect_studies.values()) ] else: label_on = 'New Material Study\'s Defect Studies' items_on = [] label_off = self.project.name + ' Defect Studies' labeltitle = tk.Label(self.main_frame, text='Defect Studies choice') self.defect_studies_choice_frame = tu.ItemsChoiceFrame( self.main_frame, items, items_on, label_on, label_off, labeltitle) # ------------------ NAVIGATION BUTTONS ---------------------- def validate(close=False): self.attributes('-topmost', True) ds_choice = self.defect_studies_choice_frame.get_choice() find_ds_to_add = [ def_study for title in ds_choice for def_study in list(self.mainwindow.projects[ self.mainwindow.currentprojectid].defect_studies.values()) if def_study.treetitle == title ] if len(ds_choice) == 0: find_ds_to_remove = [ def_study for def_study in list( self.material_study.defect_studies.values()) ] else: if self.material_study is not None: find_ds_to_remove = [ def_study for def_study in list( self.material_study.defect_studies.values()) if def_study.treetitle not in ds_choice ] else: find_ds_to_remove = [] if self.edit is False: self.material_study = ds.MaterialStudy(*find_ds_to_add) # insert in tree self.mainwindow.pm.new_material_study(self.material_study, self.project.pid) else: for def_study in find_ds_to_add: print('Adding defect study ' + def_study.treetitle + ' to Material Study ' + self.material_study.treetitle) self.mainwindow.pm.add_defect_study_to_material_study( def_study, self.material_study, self.project.pid) for def_study in find_ds_to_remove: self.mainwindow.pm.remove_defect_study_to_material_study( def_study, self.material_study, self.project.pid) if len(self.material_study.defect_studies) > 0: self.plot(close=close) else: print( 'Warning! Impossible to plot Defect Formation Energies for empty Material Study ' + self.material_study.treetitle) if close: self.cancel() self.button_pane = tk.Frame(self.main_frame, bd=2, pady=10) self.apply_button = Button(self.button_pane, text='Apply', command=validate) self.next_button = Button(self.button_pane, text='OK', command=lambda: validate(close=True)) self.cancel_button = Button(self.button_pane, text='Cancel', command=self.cancel) self.apply_button.grid(row=0, column=0) self.next_button.grid(row=0, column=1) self.cancel_button.grid(row=0, column=2) self.defect_studies_choice_frame.pack(expand=True, fill='y') self.button_pane.pack(side=BOTTOM, expand=True, fill='y') tu.centre_window(self)
for i in elenco: indirizzi += i.replace('\n', '').replace('<', '')+';' indirizzi = indirizzi[:-1] text_output.delete("1.0", END) text_output.insert("1.0", indirizzi) interfaccia = Tk() interfaccia.geometry("600x600") interfaccia.title("Email Address Extractor") testo = Frame(interfaccia, bd=3, relief="ridge", padx=15, pady=15) testo.pack() lb_input = Label(testo, text="Input:") lb_input.pack() text_input = Text(testo, bg="white", fg="black", padx=20, pady=20, height=9) text_input.pack() bt_input = Button(testo, text="Extract", command=creaelenco) bt_input.pack(pady=10) output = Frame(interfaccia, bd=3, relief="ridge", padx=15, pady=15) output.pack() lb_output = Label(output, text="Output:") lb_output.pack() text_output = Text(output, bg="white", fg="black", padx=20, pady=20, height=9) text_output.pack() bt_copy = Button(output, text="Copy to clipboard", command=lambda: pyperclip.copy(text_output.get('1.0', END))) bt_copy.pack(pady=10) interfaccia.mainloop()
'move caneta 10 pixels para direita' global x, canvas # x é modificado canvas.create_line(x, y, x + 10, y) x += 10 raiz = Tk() # tela com borda de tamanho 200 x 200 canvas = Canvas(raiz, height=200, width=200, relief=SUNKEN, borderwidth=3) canvas.pack(side=LEFT) # frame para manter os 4 botões box = Frame(raiz) box.pack(side=RIGHT) # os 4 widgets de botão têm a caixa do widget Frame como seu master button = Button(box, text='up', command=up) button.grid(row=0, column=0, columnspan=2) button = Button(box, text='left', command=left) button.grid(row=1, column=0) button = Button(box, text='right', command=right) button.grid(row=1, column=1) button = Button(box, text='down', command=down) button.grid(row=2, column=0, columnspan=2) x, y = 100, 100 # posição da caneta, inicialmente no meio raiz.mainloop()
from tkinter import Button import time import training from tkinter.filedialog import askopenfilename def get_files(): filename = askopenfilename(title="上传图片", filetypes=[('图片', 'jpg'), ('图片', 'jpeg'),('图片', 'png')]) i = 1 dir = 'D:\\deal_pics\\' + time.strftime('%Y-%m-%d') if not os.path.exists(dir): os.makedirs(dir) if filename: img = cv2.imread(filename) img = cv2.resize(img, (208, 208), interpolation=cv2.INTER_CUBIC) str1 = training.evaluate_one_image(img) newFile = filename.split('/')[-1] name = newFile.split('.')[0] cv2.imwrite(dir+'\\'+name+'.'+'jpg', img) # 保存 cv2.imshow('img', img) # cv2.waitKey(0) # cv2.destroyAllWindows() messagebox.showinfo('提示', str1) else: messagebox.showinfo('提示', '未选择图片!') root = Tk() root.title('上传') button = Button(root, text="点此上传", command=get_files,width=20,height=10) button.pack() root.geometry('300x200+500+300') root.mainloop()
rely=0, y=5, relwidth=1, width=-190, relheight=1, height=-29, anchor='nw') history = Text(container2) history.insert( 0.0, " NOTE \n------------------\nThis field records your latest rolls at its top." ) history.place(relwidth=1, relheight=1, anchor='nw') clear = Button(body, text="[clear]", command=lambda: reset(), bd=-3) clear.place(rely=1, y=-18, x=179, anchor='nw') #bottom right label info = Label(body, text=NAME, bd=-1) info.place(relx=1, rely=1, anchor='se') owner = Label(body, text="copyright or some shabbaz", bd=-1) owner.place(relx=0, rely=1, anchor='sw') #entry field templates #one = StringVar(container, value='1') aka (xdX) #zero = StringVar(container, value='+0') aka (ydX) #table headers
img = deal_photo(filename,num,dict) #得到改造后的图片 l1.config(image=img) #重新配置得改变的照片(label不会自己改变) text = '' for n in range(num): str = "人物编号:%d 性别:%s 年龄:%d 脸型:%s 颜值:%.2f 真人/卡通:%s 眼镜:%s 人种:%s\n"%(n,dict['gender'][n],dict['age'][n],dict['face_shape'][n],dict['beauty'][n],dict['face_type'][n],dict['glasses'][n],dict['human_type'][n]) text = text + str lb.config(text = text) else: lb.config(text = "文件错误!") else: lb.config(text = "您没有选择任何文件") #开始 gui事件: img = '' #初始赋值 root = tkinter.Tk() root.title('人脸识图') #主窗口标题 lb = Label(root,text = '') #lebal框 lb.pack() #pack放到窗口上 btn = Button(root,text="(选择一张人像)\n卡顿由于网络原因,请稍等!",command=xz) #按键框 btn.pack() l1=Label(root) #图片框 l1.pack() root.mainloop()
def creeTabInsertion(self): logging.info("Création de la fiche d'insertion d'un évènement") self.tabInsert = ttk.Frame(self.tabs) self.lineDateDebutInsert = ttk.Frame(self.tabInsert) self.dateDebutInsert = Label(self.lineDateDebutInsert, text="Date début") self.dateDebutInsertEntry = DateEntry(self.lineDateDebutInsert) self.heureDebutInsert = Label(self.lineDateDebutInsert, text="Heure début") self.heureDebutInsertEntry = HeureEntry(self.lineDateDebutInsert) self.dateDebutInsert.pack(side=LEFT) self.dateDebutInsertEntry.pack(side=LEFT) self.heureDebutInsert.pack(side=LEFT) self.heureDebutInsertEntry.pack(side=LEFT) self.lineDateFinInsert = ttk.Frame(self.tabInsert) self.dateFinInsert = Label(self.lineDateFinInsert, text="Date fin") self.dateFinInsertEntry = DateEntry(self.lineDateFinInsert) self.heureFinInsert = Label(self.lineDateFinInsert, text="Heure fin") self.heureFinInsertEntry = HeureEntry(self.lineDateFinInsert) self.dateFinInsert.pack(side=LEFT) self.dateFinInsertEntry.pack(side=LEFT) self.heureFinInsert.pack(side=LEFT) self.heureFinInsertEntry.pack(side=LEFT) self.lineCheck = ttk.Frame(self.tabInsert) self.varCheckInsert = IntVar() self.checkFullDay = Checkbutton(self.lineCheck, text='Full Day', variable=self.varCheckInsert, onvalue=1, offvalue=0, command=self.onFullDay) self.checkFullDay.pack() self.summaryInsert = ttk.Frame(self.tabInsert) self.summaryInsertLabel = Label(self.summaryInsert, text="Résumé") self.summaryInsertEntry = Entry(self.summaryInsert) self.summaryInsertLabel.pack(side=LEFT) self.summaryInsertEntry.pack(side=LEFT) self.descriptionInsert = ttk.Frame(self.tabInsert) self.descriptionInsertLabel = Label(self.descriptionInsert, text="Description") self.descriptionInsertEntry = Entry(self.descriptionInsert) self.descriptionInsertLabel.pack(side=LEFT) self.descriptionInsertEntry.pack(side=LEFT) self.locationInsert = ttk.Frame(self.tabInsert) self.locationInsertLabel = Label(self.locationInsert, text="Location") self.locationInsertEntry = Entry(self.locationInsert) self.locationInsertLabel.pack(side=LEFT) self.locationInsertEntry.pack(side=LEFT) self.buttonInsert = Button(self.tabInsert, text="Insérez", command=self.onInsertEvent) self.lineDateDebutInsert.pack() self.lineDateFinInsert.pack() self.lineCheck.pack() self.summaryInsert.pack() self.descriptionInsert.pack() self.locationInsert.pack() self.buttonInsert.pack(expand=True, fill=X) self.tabs.add(self.tabInsert, text="Insertion")
def resultado(raizMain, raizForm, archivo, nombre, edad, cs, oirT, FHF, ocltv, MIP, oltv, nob, oupb, olt, data, lsqn, r): meses = np.array( ["Mes 1", "Mes 2", "Mes 3", "Mes 4", "Mes 5", "Mes 6", "Mes 7"]) valores = prediccion() #parte grafica raizResult = tkinter.Toplevel(raizMain) raizForm.destroy() raizResult.title("Sistema Trackit") frameBack = Frame(raizResult) frameBack.pack() frameHead = Frame(frameBack) frameHead.grid(row=0, column=0, padx=0, pady=15) #Frame de logos y titulo presentaFra = Frame(frameHead, highlightbackground="black", highlightcolor="black", highlightthickness=1, bd=5) presentaFra.grid(row=0, column=0) tituloFra = Frame(presentaFra) tituloFra.grid(row=0, column=0) Label(tituloFra, text="Sistema de predicción de pagos", font=("Times New Roman", 18, "bold", "italic"), width=49).grid(row=0, column=0, padx=5) Label(tituloFra, text="para creditos hipotecarios", font=("Times New Roman", 18, "bold", "italic")).grid(row=1, column=0, padx=5) frameAmar = Frame(frameHead, background="#FFFB00", width="715", height="5") frameAmar.grid(row=1, column=0) frameAmar = Frame(frameHead, background="#FFFFFF", width="715", height="5") frameAmar.grid(row=2, column=0) frameAmar = Frame(frameHead, background="#0D6AE1", width="715", height="5") frameAmar.grid(row=3, column=0) frameBody = Frame(frameBack) frameBody.grid(row=1, column=0, sticky="w", pady=30) frameIzq = Frame(frameBody) frameIzq.grid(row=1, column=0, padx=5, pady=40, sticky="w") frameDer = Frame(frameBody) frameDer.grid(row=1, column=1, sticky="w") Label(frameIzq, text="Nombre", font=("", 10, "bold")).grid(row=0, column=0, sticky="w") Label(frameIzq, text=nombre, font=("", 10)).grid(row=1, column=0, sticky="w") frameEdad = Frame(frameIzq) frameEdad.grid(row=2, column=0, sticky="w") Label(frameEdad, text="Edad", font=("", 10, "bold")).grid(row=0, column=0, sticky="w") Label(frameEdad, text=edad, font=( "", 10, )).grid(row=1, column=0, sticky="w") Label(frameEdad, text="Perfil de riesgo", font=("", 10, "bold")).grid(row=0, column=1, sticky="w") Label(frameEdad, text="Alto riesgo", font=("", 10)).grid(row=1, column=1, sticky="w") Label(frameIzq, text="Valor total del credito", font=("", 10, "bold")).grid(row=3, column=0, sticky="w") Label(frameIzq, text="$193000", font=("", 10)).grid(row=4, column=0, sticky="w") Label(frameIzq, text="Valor en riesgo o perdida", font=("", 10, "bold")).grid(row=5, column=0, sticky="w") Label(frameIzq, text="$178381", font=("", 10)).grid(row=6, column=0, sticky="w") Button(frameIzq, text="Volver", bg="#AED6F1", width=10, height=1, command=lambda: VolverForm(raizResult, raizMain)).grid(row=7, column=0, pady=(20, 0)) graficar(valores, meses, frameDer) salir = Button(frameDer, text="Salir", command=lambda: Salir(raizResult, raizMain), width=10, background="#F70A0A") salir.grid(row=1, column=1, padx=20, pady=(10, 10), sticky="e")
def __init__(self, master): # Create the main window widget. self.sleep = True self.DATA = [] self.colors = { 'white': '#FFFFFF', 'blue': '#2B547E', 'black': '#000000', 'red': '#FF3346', 'green': '#306754', 'grey': '#E5E4E2', 'hex': '#9bcbff', 'button_color': '#C0C0C0' } self.check = 0 self.chosenSong = '' self.chosenId = 0 self.POP = [] self.CHILL = [] self.DANCE = [] self.check_pop = IntVar() self.check_chill = IntVar() self.check_dance = IntVar() self.master = master self.master.title('Music Player') self.master.configure(bg=self.colors['hex']) self.master.geometry('850x600') self.f_name = '' self.imagePath = tk.PhotoImage(file='Logo.png') self.rewindImg = tk.PhotoImage(file='rewind.png') self.playImage = tk.PhotoImage(file='play.png') self.pauseImage = tk.PhotoImage(file='pause.png') self.nextImage = tk.PhotoImage(file='unpause.png') self.image = tk.Label(master, image=self.imagePath, borderwidth=0, bg=self.colors['hex']) # widgets self.file_name_label = Label( master, fg=self.colors['black'], bg=self.colors['button_color'], text='Enter a name for your file: ', width=57, font='Helvetica 10 bold') self.pop = Checkbutton( master, fg=self.colors['black'], bg=self.colors['hex'], text='POP', highlightbackground=self.colors['black'], variable=self.check_pop) self.chill = Checkbutton( master, fg=self.colors['black'], bg=self.colors['hex'], text='CHILL', highlightbackground=self.colors['black'], variable=self.check_chill) self.dance = Checkbutton( master, fg=self.colors['black'], bg=self.colors['hex'], text='DANCE', highlightbackground=self.colors['black'], variable=self.check_dance) self.file_name = Text( master, fg=self.colors['blue'], bg=self.colors['grey'], width=57, height=1) self.explorer_label1 = Button( master, fg=self.colors['grey'], bg=self.colors['blue'], width=30, text='Download Tracks/Show Genres', command=self.download) self.explorer = Listbox( master, fg=self.colors['blue'], bg=self.colors['grey'], width=70, height=15, highlightcolor=self.colors['green']) self.explorer2 = Listbox( master, fg=self.colors['blue'], bg=self.colors['grey'], width=70, height=15, highlightcolor=self.colors['green']) self.search_btn = Button( master, fg=self.colors['grey'], bg=self.colors['blue'], width=30, text='Search', command=self.showGenre) self.delete_button = Button( master, fg=self.colors['white'], bg=self.colors['red'], text='DELETE', width=31, highlightbackground=self.colors['black'], command=self.delete) self.stop_button = Button( master, fg=self.colors['grey'], image=self.pauseImage, bg=self.colors['green'], text='PAUSE', width=80, font='Helvetica 10 bold', highlightbackground=self.colors['black'], command=self.stop) self.unpause_button = Button( master, fg=self.colors['grey'], image=self.playImage, bg=self.colors['green'], text='PAUSE', width=80, font='Helvetica 10 bold', highlightbackground=self.colors['black'], command=self.unpause) self.play_button = Button( master, image=self.playImage, fg=self.colors['grey'], bg=self.colors['green'], text='PLAY', width=80, highlightbackground=self.colors['black'], command=self.play) self.status_label = Label( master, fg=self.colors['grey'], bg=self.colors['black'], width=60, text='Hello') self.clear_button = Button( master, fg=self.colors['grey'], bg=self.colors['green'], text='CLEAR', width=15, highlightbackground=self.colors['black'], command=self.clear) self.rewind_button = Button( master, image=self.rewindImg, fg=self.colors['grey'], bg=self.colors['green'], text='REWIND', width=80, highlightbackground=self.colors['black'], command=self.rewind) self.next_button = Button( master, image=self.nextImage, fg=self.colors['grey'], bg=self.colors['green'], text='REWIND', width=80, highlightbackground=self.colors['black'], command=self.nextSelection) # grid self.image.grid(row=0, sticky=W + E) self.explorer.grid(row=7, sticky=W, padx=20) self.explorer2.grid(row=7, sticky=E, padx=20) self.play_button.grid(row=8, sticky=W, padx=100, pady=20) self.delete_button.grid(row=8, sticky=E, padx=20, pady=20) self.search_btn.grid(row=6, sticky=E, padx=20) self.status_label.grid(row=13, sticky=E + W, padx=20) self.rewind_button.grid(row=8, sticky=W, padx=20, pady=20) self.next_button.grid(row=8, sticky=W, padx=180, pady=20) self.file_name.grid(row=2, sticky=E, padx=20) self.displayAllData() if self.checkingConnection(): self.file_name_label.grid(row=2, sticky=W, padx=20) self.file_name.grid(row=2, sticky=E, padx=20) self.pop.grid(row=3, sticky=W, padx=100, pady=5) self.chill.grid(row=3, pady=5) self.dance.grid(row=3, sticky=E, padx=100, pady=5) self.explorer_label1.grid(row=6, sticky=W, padx=20) self.clear_button.grid(row=8, sticky=W, padx=350, pady=20)
pennies += 1 cents = round(cents - 0.01, 2) quarters_entry.delete(0, END) quarters_entry.insert(0, str(quarters)) dimes_entry.delete(0, END) dimes_entry.insert(0, str(dimes)) nickels_entry.delete(0, END) nickels_entry.insert(0, str(nickels)) pennies_entry.delete(0, END) pennies_entry.insert(0, str(pennies)) submit_button = Button(frame, width=10, text='Submit', command=submit_clicked) submit_button.grid(row=6, column=0) def clear_display(): cost_entry.delete(0, END) amount_given_entry.delete(0, END) quarters_entry.delete(0, END) dimes_entry.delete(0, END) nickels_entry.delete(0, END) pennies_entry.delete(0, END) clear_button = Button(frame, width=10, text='Clear', command=clear_display) clear_button.grid(row=6, column=1)
def buildWidgetSkeleton(self): ''' Builds the basic skeleton of our app widgets. - items marked with (*) are built directly in this function - items marked with (~) are built by the individual modules # WARNING: out of date diagram .________________________________________. | ROOT | | .____________________________________. | | | TOP* | | | | ._______________. .______________. | | | | | LEFT* | | RIGHT* | | | | | | - file nav* | | - dicom~ | | | | | | - frame nav*| | | | | | | | - traces~ | | | | | | | | - undo~ | | | | | | | \_______________/ \______________/ | | | \____________________________________/ | | | | .____________________________________. | | | BOTTOM* | | | | - spectrogram~ | | | | - textgrid~ | | | \____________________________________/ | \________________________________________/ ''' # main Frame skeleton self.TOP = Frame(self) self.TOP.columnconfigure(1, weight=1, minsize=320) self.TOP.rowconfigure(0, weight=1, minsize=240) self.LEFT = Frame(self.TOP) # self.LEFT.rowconfigure(0,weight=1) # self.LEFT.columnconfigure(0,weight=1) self.RIGHT = Frame(self.TOP) self.RIGHT.rowconfigure(0, weight=1) self.RIGHT.columnconfigure(0, weight=1) self.BOTTOM = Frame(self) # self.BOTTOM.columnconfigure(0,weight=1) self.BOTTOM.columnconfigure(1, weight=1) # self.BOTTOM.rowconfigure(0,weight=1) # self.TOP.grid( row=0, column=0, sticky='nw') # self.LEFT.grid( row=0, sticky='n' ) # self.RIGHT.grid( row=0, column=1) # self.BOTTOM.grid( row=1, column=0, sticky='e') self.TOP.grid(row=0, column=0, sticky='nesw') self.LEFT.grid(row=0, sticky='nesw') self.RIGHT.grid(row=0, column=1, sticky='nesw') self.BOTTOM.grid(row=1, column=0, sticky='nesw') self.pady = 3 self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) # navigate between all available filenames in this directory self.filesFrame = Frame(self.LEFT) #, pady=7) self.filesPrevBtn = Button(self.filesFrame, text='<', command=self.filesPrev, takefocus=0) self.filesJumpToMenu = OptionMenu(self.filesFrame, self.currentFileSV, *self.Data.files, command=self.filesJumpTo) self.filesNextBtn = Button(self.filesFrame, text='>', command=self.filesNext, takefocus=0) self.filesFrame.grid(row=1) self.filesPrevBtn.grid(row=1, column=0) self.filesJumpToMenu.grid(row=1, column=1) self.filesNextBtn.grid(row=1, column=2) Header(self.filesFrame, text="Choose a file:").grid(row=0, column=0, columnspan=3) # navigate between frames self.framesFrame = Frame(self.LEFT) #, pady=7) self.framesSubframe = Frame(self.framesFrame) self.framesPrevBtn = Button(self.framesSubframe, text='<', command=self.framesPrev, takefocus=0) self.framesEntryText = Entry(self.framesSubframe, width=5, textvariable=self.frameSV) self.framesEntryBtn = Button(self.framesSubframe, text='Go', command=self.framesJumpTo, takefocus=0) self.framesNextBtn = Button(self.framesSubframe, text='>', command=self.framesNext, takefocus=0) self.framesHeader = Header(self.framesFrame, text="Choose a frame:") self.framesFrame.grid(row=3) self.framesSubframe.grid(row=1) # non-module-specific bindings if util.get_platform() == 'Linux': self.bind('<Control-Left>', self.filesPrev) self.bind('<Control-Right>', self.filesNext) else: self.bind('<Option-Left>', self.filesPrev) self.bind('<Option-Right>', self.filesNext) self.bind('<Left>', self.framesPrev) self.bind('<Right>', self.framesNext) self.bind('<BackSpace>', self.onBackspace) self.bind('<Button-1>', self.getWinSize) self.bind('<ButtonRelease-1>', self.onRelease) self.bind('<Double-Button-1>', self.onDoubleClick) self.bind('<Escape>', self.onEscape) # self.count = 0 self.framesEntryText.bind('<Return>', self.unfocusAndJump) self.framesEntryText.bind('<Escape>', lambda ev: self.framesFrame.focus()) # force window to front self.lift()
def register_gp(): """Tkinter programme for gp registration. :return: register_gp_button(). """ gp_register = Toplevel() gp_register.title("Register to create an account") gp_register.geometry("500x400") Label( gp_register, text="Enter your details to make an account.\n" "Your details will need to be verified by an admin before you can login." ).grid(row=0, column=2, padx=40) first_name_label = Label(gp_register, text="First name:") first_name_label.grid(row=1, column=2) first_name_entry = Entry(gp_register) first_name_entry.grid(row=2, column=2) last_name_label = Label(gp_register, text="Last name:") last_name_label.grid(row=3, column=2) last_name_entry = Entry(gp_register) last_name_entry.grid(row=4, column=2) username_label = Label(gp_register, text="Create Username:"******"Create Password:"******"*") gp_password_entry.grid(row=8, column=2) gmc_label = Label(gp_register, text="7-digit GMC Number") gmc_label.grid(row=9, column=2) gmc_entry = Entry(gp_register) gmc_entry.grid(row=10, column=2) def register_gp_button(): """Creates new GP profile. Entered into json gp database. :return: messagebox for registration confirmation. """ error = 0 gp_database = json.load(open("gp_database.json")) # checks if all fields were filled if (gp_username_entry.get() == "" or gp_password_entry.get() == "" or first_name_entry.get() == "" or last_name_entry.get() == "" or gmc_entry.get() == ""): Label(gp_register, text="Please enter all required fields.").grid(row=12, column=2) logger.info("Empty fields for gp registration.") error += 1 # checks the format of the username, name and if the username is unique if gp_username_entry.get() in gp_database.keys(): gp_register.geometry("800x400") Label(gp_register, text="Username already taken. Please choose another.").grid( row=6, column=3) logger.warning("Username already in database.") gp_username_entry.delete(0, END) error += 1 if gp_username_entry == " ": gp_register.geometry("800x400") Label(gp_register, text="Please enter a valid username.").grid(row=6, column=3) logger.info("Space given as username.") gp_username_entry.delete(0, END) error += 1 if first_name_entry.get() == " ": gp_register.geometry("800x400") Label(gp_register, text="Please enter your given first name.").grid(row=2, column=3) logger.info("Space given as first name.") first_name_entry.delete(0, END) error += 1 if any(i.isdigit() for i in first_name_entry.get()): gp_register.geometry("800x400") Label(gp_register, text="Please enter your given first name.").grid(row=2, column=3) logger.info("Number in first name. Invalid input.") first_name_entry.delete(0, END) error += 1 if last_name_entry.get() == " ": gp_register.geometry("800x400") Label(gp_register, text="Please enter your given last name.").grid(row=4, column=3) logger.info("Space given as last name.") last_name_entry.delete(0, END) error += 1 if any(i.isdigit() for i in last_name_entry.get()): gp_register.geometry("800x400") Label(gp_register, text="Please enter your given last name.").grid(row=4, column=3) logger.info("Number in last name. Invalid input.") last_name_entry.delete(0, END) error += 1 # checks the format of GMC number if len(gmc_entry.get()) != 7: gp_register.geometry("800x400") Label(gp_register, text="GMC Number Invalid - Please enter 7 digits.").grid( row=10, column=3) logger.info("GMC number length invalid.") gmc_entry.delete(0, END) error += 1 try: int(gmc_entry.get()) except ValueError: gp_register.geometry("800x400") Label(gp_register, text="GMC Number Invalid - Please enter 7 digits").grid( row=10, column=3) logger.info("GMC number input not integers.") gmc_entry.delete(0, END) error += 1 # checks if the GMC number is unique gmc_list = [] for gp in gp_database.keys(): gmc_list.append(str(gp_database[gp]['GMC_Number'])) if str(gmc_entry.get()) in gmc_list: gp_register.geometry("800x400") Label(gp_register, text="GMC Number Invalid - already registered.").grid( row=10, column=3) logger.warning("GMC number already in database.") gmc_entry.delete(0, END) error += 1 json.dump(gp_database, open('gp_database.json', 'w')) if error == 0: gp_database = json.load(open('gp_database.json')) gp_database[gp_username_entry.get()] = { "username": gp_username_entry.get(), "password": gp_password_entry.get(), "First Name": first_name_entry.get(), "Last Name": last_name_entry.get(), "GMC_Number": gmc_entry.get(), "assigned_patients": [], "Verified": False, "Holidays": [], "Availability": { "Monday Start": "09:00", "Monday End": "16:50", "Tuesday Start": "09:00", "Tuesday End": "16:50", "Wednesday Start": "09:00", "Wednesday End": "16:50", "Thursday Start": "09:00", "Thursday End": "16:50", "Friday Start": "09:00", "Friday End": "16:50", "Lunch": "13:00" } } json.dump(gp_database, open('gp_database.json', 'w')) logger.info("New GP Profile created: {}".format( gp_username_entry.get())) gp_register.destroy() messagebox.showinfo( "Registration", "Thank you for registering your details. These will be reviewed by a " "member of the admin team within 24 hours, who will then " "activate your account.") Button(gp_register, text="Register", command=register_gp_button).grid(row=11, column=2, pady=10)
def make_widgets(self): Label(self, text='Hashtag to search:', width=40).pack() self.hashT = Entry(self, width=40) self.hashT.pack() Button(self, text='Submit', command=lambda: self.calc_reponse()).pack()
def register_patient(): """Tkinter programme for registering patients as json database entries. :return: register_button(). """ register_screen = Toplevel() register_screen.title("Register to create an account") register_screen.geometry("720x550") Label(register_screen, text="Please enter your details to create an account\n" "Your details will need to be verified by an admin\n" "before you can sign in.").grid(row=0, column=1) first_name_label = Label(register_screen, text="First name:") first_name_label.grid(row=1, column=1) first_name_entry = Entry(register_screen) first_name_entry.grid(row=2, column=1) last_name_label = Label(register_screen, text="Last name:") last_name_label.grid(row=3, column=1) last_name_entry = Entry(register_screen) last_name_entry.grid(row=4, column=1) genders_label = Label(register_screen, text="Gender:") genders_label.grid(row=5, column=1) genders_options = ttk.Combobox(register_screen) genders_options["values"] = ("Male", "Female", "Prefer not to say") genders_options.grid(row=6, column=1) dob_label = Label(register_screen, text="Date of Birth:") dob_label.grid(row=7, column=1) day_options = ttk.Combobox(register_screen) day_options["values"] = ("Day", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31") day_options.current(0) day_options.grid(row=8, column=0, padx=5) month_options = ttk.Combobox(register_screen) month_options["values"] = ("Month", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12") month_options.current(0) month_options.grid(row=8, column=1) year_options = ttk.Combobox(register_screen) year_options["values"] = ( "Year", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", "1943", "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932", "1931", "1930", "1929", "1928", "1927", "1926", "1925", "1924", "1923", "1922", "1921", "1920") year_options.current(0) year_options.grid(row=8, column=2) phone_number_label = Label(register_screen, text="Telephone number:") phone_number_label.grid(row=9, column=1) phone_number_entry = Entry(register_screen) phone_number_entry.grid(row=10, column=1) nhs_number_label = Label(register_screen, text="NHS number:") nhs_number_label.grid(row=11, column=1) nhs_number_entry = Entry(register_screen) nhs_number_entry.grid(row=12, column=1) username_label = Label(register_screen, text="Create Username:"******"Create Password:"******"*") password_entry.grid(row=16, column=1) def register_button(): """Creates patient entry in json database. :return: messagebox for registration success. """ error = 0 if (username_entry.get() == "" or password_entry.get() == "" or first_name_entry.get() == "" or last_name_entry.get() == "" or genders_options.get() == "" or nhs_number_entry.get() == "" or day_options.get() == "" or month_options.get() == "" or year_options.get() == "" or phone_number_entry.get() == ""): Label(register_screen, text="Please enter all required fields.").grid(row=18, column=1) logging.info("Empty fields for patient registration.") error += 1 database = json.load(open("database.json")) # checks formats of username and name + checks if username is unique if username_entry.get() in database.keys(): register_screen.geometry("1000x550") Label(register_screen, text="Username already taken. Please choose another.").grid( row=14, column=4) logging.warning("Username already in patient database.") username_entry.delete(0, END) error += 1 if username_entry.get() == " ": register_screen.geometry("1000x550") Label(register_screen, text="Invalid username. Please choose another.").grid( row=14, column=4) logging.info("Space given as username.") error += 1 if any(i.isdigit() for i in first_name_entry.get()): register_screen.geometry("1000x550") Label(register_screen, text="Please enter your given first name.").grid(row=2, column=4) logging.info("Digit in first name. Invalid input.") first_name_entry.delete(0, END) error += 1 if first_name_entry.get() == " ": register_screen.geometry("1000x550") Label(register_screen, text="Please enter your given first name.").grid(row=2, column=4) logging.info("Space given as first name.") first_name_entry.delete(0, END) error += 1 if any(i.isdigit() for i in last_name_entry.get()): register_screen.geometry("1000x550") Label(register_screen, text="Please enter your given last name.").grid(row=4, column=4) logging.info("Digit in last name. Invalid input.") last_name_entry.delete(0, END) error += 1 if last_name_entry.get() == " ": register_screen.geometry("1000x550") Label(register_screen, text="Please enter your given last name.").grid(row=4, column=4) logging.info("Space given as last name.") last_name_entry.delete(0, END) error += 1 # checks gender option format if genders_options.get() not in genders_options["values"]: register_screen.geometry("1000x550") Label(register_screen, text="Please choose a valid option.").grid(row=6, column=4) logging.info("Invalid gender entered.") error += 1 # checks the validity of date of birth try: datetime.date(int(year_options.get()), int(month_options.get()), int(day_options.get())) except ValueError: register_screen.geometry("1000x550") Label(register_screen, text="Invalid Date of Birth Entered.").grid(row=8, column=4) logging.info("Invalid date of birth entered.") error += 1 # checks the format of telephone number try: int(phone_number_entry.get()) except ValueError: register_screen.geometry("1000x550") Label(register_screen, text="Telephone number must be 11 digits.").grid(row=10, column=4) logging.info("Telephone number not integers.") phone_number_entry.delete(0, END) error += 1 if len(str(phone_number_entry.get())) != 11: register_screen.geometry("1000x550") Label(register_screen, text="Telephone number must be 11 digits.").grid(row=10, column=4) logging.info("Telephone number not 11 digits.") phone_number_entry.delete(0, END) error += 1 # checks the format of the NHS number try: int(nhs_number_entry.get()) except ValueError: register_screen.geometry("1000x550") Label(register_screen, text="Invalid NHS number").grid(row=12, column=4) logging.info("NHS number input not integers.") nhs_number_entry.delete(0, END) error += 1 if len(str(nhs_number_entry.get())) != 10: register_screen.geometry("1000x550") Label(register_screen, text="Invalid NHS number - Please enter 10 digits.").grid( row=12, column=4) logging.info("NHS number not 10 integers.") nhs_number_entry.delete(0, END) error += 1 # checks if NHS number already in the database nhs_list = [] for patient in database.keys(): nhs_list.append(str(database[patient]['NHS_number'])) if str(nhs_number_entry.get()) in nhs_list: register_screen.geometry("1000x550") Label(register_screen, text="Invalid NHS number - number already registered").grid( row=12, column=4) logging.warning("NHS number already in database.") nhs_number_entry.delete(0, END) error += 1 json.dump(database, open("database.json", "w")) if error == 0: database = json.load(open('database.json')) database[username_entry.get()] = { "username": username_entry.get(), "password": password_entry.get(), "First Name": first_name_entry.get(), "Last Name": last_name_entry.get(), "gender": genders_options.get(), "DOB": day_options.get() + "/" + month_options.get() + "/" + year_options.get(), "tel_number": phone_number_entry.get(), "regular_drugs": [], "prescriptions": [], "NHS_number": nhs_number_entry.get(), "assigned_gp": "", "Verified": False, "Feedback": [], "Notes": [], "Allergies": [], 'Referral': '' } json.dump(database, open('database.json', 'w')) logger.info("New Patient Profile created: {}".format( username_entry.get())) register_screen.destroy() messagebox.showinfo( "Registration", "Thank you for registering your details. These will be reviewed by a " "member of the admin team within 24 hours, who will then activate " "your account.") Button(register_screen, text="Register", command=register_button).grid(row=17, column=1, pady=10)
tables_num = len(doc.tables) path_entry = Entry(frame_1) path_entry.grid(column=1, row=3) word = '' var = IntVar() checkbox = Checkbutton(frame_1, text=f'Clean this {word} word', variable=var, bg='slategray1') checkbox.grid(column=2, row=7) botao_data = Button(frame_1, width='25', height='1', text='Do it!', bg='slategray3', command=lambda: [feriados_retirar(), paragraph_replace()]) botao_data.grid(column=1, row=7) def paragraph_reading(): global doc global texto for n in range(0, paragraphs_num): texto += str(doc.paragraphs[n].text) + '\n' paragraph_reading() phrase = ''
createThread(connectToServer) master.destroy() master = Tk() master.resizable(0, 0) master.config(padx=10, pady=10) Label(master, text="Ip address:").grid(row=1, column=0, pady=5) ip = Entry(master, width=50) ip.grid(row=2, column=0) Label(master, text="Port:").grid(row=3, column=0, pady=5) port = Entry(master, width=50) port.grid(row=4, column=0) master.title("Setup connection") ip.focus_set() button = Button(master, text="OK", width=10, command=callback) button.grid(row=6, column=0) master.mainloop() # Game # Game setting pygame.font.init() myfont = pygame.font.Font(os.path.join( 'assets', 'PressStart2P-Regular.ttf'), 16) title = "Dino (client)" displayW = 1024 displayH = 576 screen = pygame.display.set_mode((displayW, displayH)) pygame.display.set_caption(title) background = 255, 255, 255