def __init__(self, master): super().__init__(master) self.Tops = Frame(self, width=1599, height=60, bg="dark green", relief=SUNKEN) self.Tops.pack(fill=X, side=TOP) self.f1 = Frame(self, width=1500, height=700, bg="white") self.f1.pack(side=LEFT, fill=BOTH) self.lblInfo = Label( self.Tops, font=('times new roman', 35, 'bold'), text= " . . . . .ELECTION COMMISSION OF PAKISTAN. . . . . ", fg="dark green", bd=10, anchor='center') self.lblInfo.grid(row=0, column=0) self.localtime = time.asctime(time.localtime(time.time())) self.lbl1 = Label(self.Tops, font=('times new roman', 10), text=self.localtime, fg="black", bd=10) self.lbl1.grid(row=1, column=0) self.name = ttk.Label(self.f1, text="CANDIDATE REGISTRATION", relief=SUNKEN) self.name.configure(background="dark green", foreground="white", font=('TIMES NEW ROMAN', 25)) self.name.grid(row=45, column=0, padx=30, pady=20) self.name = ttk.Label(self.f1, text="Candidate Name") self.name.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.name.grid(row=50, column=0) self.name_entry = ttk.Entry(self.f1) self.name_entry.grid(row=53, column=0, padx=10) self.location = ttk.Label(self.f1, text="Location") self.location.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.location.grid(row=90, column=0) self.f2 = Frame(self, width=1500, height=700, bg="white") self.f2.pack(side=RIGHT) self.filename = PhotoImage( file="C:\\Users\\atikul saikh\\Desktop\\a2.png") self.background_label = Label(self.f2, image=self.filename) self.background_label.grid(row=0, column=0) self.location_entry = StringVar() self.combobox = ttk.Combobox(self.f1, textvariable=self.location_entry) data = [] cur = db.cursor() cur.execute("SELECT * FROM location") result = cur.fetchall() for row in result: data.append(row[1]) self.combobox[ 'values'] = data #giving value to combobox which have been stored in list data self.combobox.grid(row=91, column=0, padx=10) self.party = ttk.Label(self.f1, text="Select Party") self.party.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.party.grid(row=100, column=0) self.party_entry = StringVar() self.combobox1 = ttk.Combobox(self.f1, textvariable=self.party_entry) self.combobox1.config(values=("PTI", "PML-N", "PPP", "MQM")) self.combobox1.grid(row=101, column=0) self.photo = ttk.Label(self.f1, text="Upload Photo") self.photo.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.photo.grid(row=110, column=0) self.photo_upload = ttk.Button(self.f1, text="Upload file", command=self.upload) self.photo_upload.grid(row=115, column=0) #self.submit=ttk.Button(self.f1, text="Submit",command=self.add) self.submit = Button(self.f1, font=('times new roman', 10), padx=5, pady=5, bd=5, fg="white", text="SUBMIT", bg="dark green", height=1, width=5, command=self.add) self.submit.grid(row=125, column=0, padx=20, pady=20) self.pack() image = ""
answers.append(file.readline()) correctLetter = file.readline() correctLetter = correctLetter[:-1] questions.append(Question(questionString, answers, correctLetter)) line = file.readline() file.close() index = -1 right = 0 marks=0 number_of_questions = len(questions) window = Tk() window.geometry('1000x1000') logo1 = PhotoImage(file="difficult.png") w2 = Label(window, image=logo1,width=700,height=200).pack(side="top") logo = PhotoImage(file="difficult1.png") w1 = Label(window, image=logo,width=150,height=200).pack(side="right") logo2 = PhotoImage(file="difficult1.png") w3 = Label(window, image=logo2,width=150,height=200).pack(side="left") label= Label(window, text="Welcome To Online Python Quiz",justify="left",width="150",height="2",font=("Lucida Handwriting",20),fg="medium blue",bg="white") label.pack() label= Label(window, text="Instructions",width="150",height="2",font=("Lucida Handwriting",20),fg="maroon1",bg="white") label.pack() print("\n")
def __init__(self, install_dir, beta=False): self.install_dir = install_dir self.beta = beta if IS_EXE: self.current_version = get_current_version() self.latest_version = get_latest_version() if self.latest_version is None or self.current_version is None: self.needs_update = False else: self.needs_update = self.current_version < self.latest_version else: self.current_version = None self.latest_version = None self.needs_update = False self._shutdown_handlers = [] self._shutting_down = False self.root = tk.Tk(className="Modlunky2") # Equilux Black self.root.title("Modlunky 2") self.root.geometry(f"{MIN_WIDTH}x{MIN_HEIGHT}") self.root.minsize(MIN_WIDTH, MIN_HEIGHT) self.root.grid_columnconfigure(0, weight=1) self.root.grid_rowconfigure(0, weight=0) self.root.grid_rowconfigure(1, weight=1) self.root.grid_rowconfigure(2, weight=0) # self.root.resizable(False, False) self.icon_png = PhotoImage(file=BASE_DIR / "static/images/icon.png") self.root.iconphoto(False, self.icon_png) if self.needs_update: update_button = ttk.Button(self.root, text="Update Modlunky2!", command=self.update) update_button.grid(column=0, row=0) # Handle shutting down cleanly self.root.protocol("WM_DELETE_WINDOW", self.quit) self.tabs = {} self.tab_control = ttk.Notebook(self.root) self.register_tab( "Pack Assets", PackTab( tab_control=self.tab_control, install_dir=install_dir, ), ) self.register_tab( "Extract Assets", ExtractTab( tab_control=self.tab_control, install_dir=install_dir, ), ) self.register_tab( "Levels", LevelsTab( tab_control=self.tab_control, install_dir=install_dir, ), ) self.tab_control.bind("<<NotebookTabChanged>>", self.on_tab_change) self.tab_control.grid(column=0, row=1, sticky="nsew") self.console = ConsoleWindow(self.root) self.console.grid(column=0, row=2, sticky="ew")
if __name__ == '__main__': multiprocessing.freeze_support() #Super cool json file with open('./json_settings.json', 'r') as settingsfile: jsondata = settingsfile.read() loadedjsonsettings = json.loads(jsondata) settingsfile.close() #beutiful gui root = Tk() root.title('Open_Clicker ' + loadedjsonsettings['about']['displayVersion']) root.config(bg='#0F151D') root.resizable(0, 0) root.tk.call('wm', 'iconphoto', root._w, PhotoImage(file='./favicon.png')) #high quality 10/10 button shit for the modern skid buttonFrame = Frame(root, bg='#0F151D') buttonFrame.pack(side=LEFT) #Start/Stop button toggleButtonImage = PhotoImage(file='./icons/general/play.png') toggleButton = Button( buttonFrame, command=lambda: toggle(lcbbuttonvar.get(), mcbbuttonvar.get(), rcbbuttonvar.get(), keyboardentry.get(), cpsvalue.get(), loadedjsonsettings), image=toggleButtonImage, bg='#2B2D31', fg='#C96C00', activebackground='#1E1B15', activeforeground='#066D9F')
states = [ 'active', 'alternate', 'background', 'disabled', 'focus', 'invalid', 'pressed', 'readonly', 'selected' ] # Create rasio buttons which will display widget states state_val = StringVar() for iy, state in enumerate(states): st_rb = Radiobutton(fr, value=state, text=state, variable=state_val, command=change_state) st_rb.grid(column=0, row=iy, padx=5, pady=5, sticky='nw') img1 = PhotoImage("combo-n", file='../images/piratz/combo-n.png') img2 = PhotoImage("combo-ra", file='../images/piratz/combo-ra.png') img3 = PhotoImage("combo-rd", file='../images/piratz/combo-rd.png') img4 = PhotoImage("combo-rf", file='../images/piratz/combo-rf.png') img5 = PhotoImage("combo-rn", file='../images/piratz/combo-rn.png') img6 = PhotoImage("combo-rp", file='../images/piratz/combo-rp.png') img7 = PhotoImage("comboarrow-a", file='../images/piratz/comboarrow-a.png') img8 = PhotoImage("comboarrow-d", file='../images/piratz/comboarrow-d.png') img9 = PhotoImage("comboarrow-n", file='../images/piratz/comboarrow-n.png') img10 = PhotoImage("comboarrow-p", file='../images/piratz/comboarrow-p.png') style = Style() # both theme_create and theme_settings worked #style.theme_create( "yummy", parent="clam", settings={ style.theme_settings( 'default',
self.sbody.grid_forget() self.body.grid() self.reset_btn.config(state=tk.NORMAL) self.hint_btn.config(state=tk.NORMAL) # https://www.imgonline.com.ua/eng/cut-photo-into-pieces.php # https://stackoverflow.com/questions/34570344/check-if-15-puzzle-is-solvable # https://www.geeksforgeeks.org/check-instance-15-puzzle-solvable/ if __name__ == '__main__': root = tk.Tk() root.title('Picture Puzzle') root.geometry('400x500+450+130') white_bg = PhotoImage(file='icons/white_bg.png') refresh_icon = PhotoImage(file='icons/refresh.png') hint_icon = PhotoImage(file='icons/hint.png') solved_icon = PhotoImage(file='icons/solved.png') rain_list = [PhotoImage(file=f'images/rain/img{index}.png') for index in range(1,17)] car_list = [PhotoImage(file=f'images/car/img{index}.png') for index in range(1,17)] nature_list = [PhotoImage(file=f'images/nature/img{index}.png') for index in range(1,17)] night_list = [PhotoImage(file=f'images/night/img{index}.png') for index in range(1,17)] superhero_list = [PhotoImage(file=f'images/superhero/img{index}.png') for index in range(1,17)] universe_list = [PhotoImage(file=f'images/universe/img{index}.png') for index in range(1,17)] rain_sol = PhotoImage(file='images/rain_resized.png') car_sol = PhotoImage(file='images/car_resized.png') nature_sol = PhotoImage(file='images/nature_resized.png') night_sol = PhotoImage(file='images/night_resized.png')
if __name__ == "__main__": if not (os.path.isfile('./history.csv')): init = tk.Tk() label = Label(init, text="Let's get you started by setting a budget plan!") l1 = Label(init, text="Daily target : ") l2 = Label(init, text="Currency : ") e1 = Entry(init) e2 = Entry(init) label.grid(row=1, column=1, columnspan=2, sticky='nwes') l1.grid(row=2, column=1, sticky='nwes') l2.grid(row=3, column=1, sticky='nwes') e1.grid(row=2, column=2, sticky='nwes') e2.grid(row=3, column=2, sticky='nwes') photo = PhotoImage(file=resource_path("empty.gif")) photolab = Label(init, image=photo) photolab.image = photo photolab.grid(row=5, column=1, columnspan=2, sticky='nwes') def end(): try: global target global cur target = float(e1.get()) cur = e2.get() init.destroy() except ValueError: messagebox.showerror( "Error", "Make sure your target is an integer, and your currency is valid"
from tkinter import Tk, Frame, Label, PhotoImage root = Tk() root.title("Probando el widget Label") root.resizable(width=True, height=True) root.iconbitmap("icon.ico") root.config(bg="lightblue") frame = Frame(root, width=500, height=400) frame.pack() imagen = PhotoImage(file="avengers.png") Label(frame, image=imagen).pack() # .place() es otra posibilidad root.mainloop()
for x in range(x_start, x_start + SWATCH_SIZE - 1): for y in range(y_start, y_start + SWATCH_SIZE - 1): image.put("#%02x%02x%02x" % color, (x, y)) window = Tk() window.title('Soft Palette') canvas = Canvas(window, width=PALETTE_WIDTH, height=PALETTE_HEIGHT, bg='#000000') canvas.pack() file = '../palettes/soft_color_palette.png' print('creating', file) img = PhotoImage(width=PALETTE_WIDTH, height=PALETTE_HEIGHT) canvas.create_image((PALETTE_WIDTH // 2, PALETTE_HEIGHT // 2), image=img, state='normal') canvas.image = img # To prevent garbage collection for row in range(PALETTE_ROWS): print('ROW --------------------------------') for col in range(PALETTE_COLUMNS): hue_column = col // 5 hue = hue_layout[row][hue_column] value = 2 * (col % 5) + 1 chroma = chroma_curve[value] if hue != gray else 0 print('hue value chroma', hue, value, chroma) rgb_color = munsell.to_rgb(hue, value, chroma) if rgb_color is not None:
def __init__(self, win: Tk, msg: str, sender: str): super().__init__(win, msg) self.media_from = f"From: {sender}".encode() self.MSG_FONT = ("Helvetica", 8, "normal") self.MESSSAGE_BG = "gray73" self.doc_image = PhotoImage(file="doc.png")
def create_card_images(self): self.face_img = PhotoImage(file=self.face_img_path) self.back_img = PhotoImage(file=self.back_img_path)
#calculate mandelbrot x,y coordinates for each screen pixel xm = [xa + (xb - xa) * kx / x for kx in range(x)] ym = [ya + (yb - ya) * ky / y for ky in range(y)] #build the Photoimage string by calling mandel_pixel to index in the color table return " ".join((("{" + " ".join(clr[mandel_pixel(complex(i, j))] for i in xm)) + "}" for j in ym)) #window size x = 640 y = 480 #corners of the mandelbrot plan to display xa = -2.0 xb = 1.0 ya = -1.27 yb = 1.27 #Tkinter window window = Tk() canvas = Canvas(window, width=x, height=y, bg="#000000") canvas.pack() img = PhotoImage(width=x, height=y) canvas.create_image((0, 0), image=img, state="normal", anchor=NW) #do the mandelbrot t1 = clock() img.put(mandelbrot(xa, xb, ya, yb, x, y)) print(clock() - t1, ' seconds') mainloop()
def __init__(self, master): super().__init__(master) self.Tops = Frame(self, width=1200, height=100, bg="dark green", relief=SUNKEN) self.Tops.pack(fill=X, side=TOP) self.f1 = Frame(self, width=400, height=700, bg="white") self.f1.pack(fill=Y, side=LEFT) self.f2 = Frame(self, width=800, height=1200, bg="white") self.f2.pack(fill=BOTH) self.f3 = Frame(self, width=800, height=200, bg="white") self.f3.pack(side=BOTTOM, fill=BOTH) self.lblInfo = Label( self.Tops, font=('times new roman', 35, 'bold'), text=" . . . .THE ELECTION COMMISSION OF PAKISTAN. . . . ", fg="dark green", bd=10, anchor='center') self.lblInfo.grid(row=0, column=0) self.localtime = time.asctime(time.localtime(time.time())) self.lbl1 = Label(self.Tops, font=('times new roman', 10), text=self.localtime, fg="black", bd=10) self.lbl1.grid(row=1, column=0) self.filename = PhotoImage( file="C:\\Users\\atikul saikh\\Desktop\\a7.png") self.background_label = Label(self.f1, image=self.filename, anchor="center") self.background_label.grid(column=0, row=0, sticky="wens", padx=0, pady=90) self.filename1 = PhotoImage( file="C:\\Users\\atikul saikh\\Desktop\\a8.png") self.background_label1 = Label(self.f3, image=self.filename1, anchor="center") self.background_label1.grid(row=0, column=0) self.name = ttk.Label(self.f2, text="VOTER'S REGISTRATION", relief=SUNKEN) self.name.configure(background="dark green", foreground="white", font=('TIMES NEW ROMAN', 25)) self.name.grid(row=3, column=0, padx=10, pady=20) self.name = ttk.Label(self.f2, text="Name") self.name.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.name.grid(row=5, column=0) self.name_entry = ttk.Entry(self.f2) self.name_entry.grid(row=5, column=1, padx=5, pady=5) self.age = ttk.Label(self.f2, text="Age") self.age.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.age.grid(row=10, column=0) self.age_entry = ttk.Entry(self.f2) self.age_entry.grid(row=10, column=1, padx=5, pady=5) self.cnic = ttk.Label(self.f2, text="Cnic") self.cnic.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.cnic.grid(row=15, column=0) self.cnic_entry = ttk.Entry(self.f2) self.cnic_entry.grid(row=15, column=1, padx=5, pady=5) self.gend = ttk.Label(self.f2, text="Gender") self.gend.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.gend.grid(row=20, column=0) self.gender = StringVar() self.combobox1 = ttk.Combobox( self.f2, textvariable=self.gender ) #selected value stored in self.location variable. self.combobox1.config(values=("Male", "Female")) self.combobox1.grid(row=20, column=1, padx=5, pady=5) self.loc = ttk.Label(self.f2, text="Location") self.loc.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.loc.grid(row=25, column=0) self.location = StringVar() # the selected value will be stored in it self.combobox = ttk.Combobox( self.f2, textvariable=self.location ) #selected value stored in self.location variable. data = [] cur = db.cursor() cur.execute("SELECT * FROM location") result = cur.fetchall() for row in result: data.append(row[1]) self.combobox[ 'values'] = data #giving value to combobox which have been stored in list data self.combobox.grid(row=25, column=1, padx=5, pady=5) boldStyle = ttk.Style() boldStyle.configure("Bold.TButton", font=('Calibiri', '12', 'bold'), foreground="green") boldStyle.configure("Bold.TButton", font=('Calibiri', '12', 'bold'), foreground="black") self.add_voter = ttk.Button(self.f2, style="Bold.TButton", text="Submit", command=self.add_voter_submit) self.add_voter.grid(row=30, columnspan=4, padx=10, pady=10) self.pack()
def __init__(self, master): super().__init__(master) self.Tops = Frame(self, width=1200, height=100, bg="dark green", relief=SUNKEN) self.Tops.pack(fill=X, side=TOP) self.f1 = Frame(self, width=400, height=700, bg="black") self.f1.pack(side=LEFT) self.f2 = Frame(self, width=800, height=700, bg="white") self.f2.pack(fil=BOTH) self.lblInfo = Label( self.Tops, font=('times new roman', 35, 'bold'), text=" . . . . .RESULTS OF ELECTIONS 2018. . . . . ", fg="dark green", bd=10, anchor='center') self.lblInfo.grid(row=0, column=0, padx=80, pady=20) self.localtime = time.asctime(time.localtime(time.time())) self.lbl1 = Label(self.Tops, font=('times new roman', 10), text=self.localtime, fg="black", bd=10) self.lbl1.grid(row=1, column=0) self.filename = PhotoImage( file="C:\\Users\\atikul saikh\\Desktop\\abc.png") self.background_label = Label(self.f1, image=self.filename, anchor="s") self.background_label.grid(column=0, row=0, sticky="wens") self.loc = ttk.Label(self.f2, text="Location") self.loc.configure(background="White", foreground="dark green", font=('TIMES NEW ROMAN', 20)) self.loc.grid(row=2, column=0) self.location = StringVar() self.combobox = ttk.Combobox(self.f2, textvariable=self.location) # Fetch location from Database data = [] cur = db.cursor() cur.execute("SELECT * FROM location") result = cur.fetchall() for row in result: data.append(row[1]) self.combobox[ 'values'] = data #giving value to combobox which have been stored in list data self.combobox.grid(row=3, column=0, padx=5, pady=5) boldStyle = ttk.Style() boldStyle.configure("Bold.TButton", font=('Calibiri', '12', 'bold'), foreground="green") self.submit_button = ttk.Button(self.f2, style="Bold.TButton", text="Submit", command=self.view_result) self.submit_button.grid(row=5, columnspan=4, padx=10, pady=10) self.pack() global list1 list1 = []
# http://stackoverflow.com/questions/12284311/python-tkinter-how-to-work-with-pixels from tkinter import Tk, Canvas, PhotoImage, mainloop from math import sin WIDTH, HEIGHT = 640, 480 window = Tk() canvas = Canvas(window, width=WIDTH, height=HEIGHT, bg="#000000") canvas.pack() img = PhotoImage(width=WIDTH, height=HEIGHT) canvas.create_image((WIDTH / 2, HEIGHT / 2), image=img, state="normal") for x in range(4 * WIDTH): y = int(HEIGHT / 2 + HEIGHT / 4 * sin(x / 80.0)) img.put("#ffffff", (x // 4, y)) mainloop()
from tkinter import Tk, PhotoImage, Label, Button # root: root = Tk() root.title("Охота на пришельцев") root.resizable(False, False) # background: img = PhotoImage(file="planet.png") bg = Label(root, image=img) bg.pack() # start: root.mainloop()
def __init__(self, master): # colour swatches self.gray1 = "#f6f6f6" self.gray2 = "#eaeaea" self.gray3 = "#d9d9d9" # key parameters self.running = False self.sect_width = 360 self.rb_choice = StringVar() self.dob1_val = StringVar() self.dob2_val = StringVar() self.df_records = StringVar() master.geometry("800x600+200+200") master.title("Red Snapper") master.resizable(False, False) master.configure(background=self.gray1) # LEFT SECTION LAYER # -------------------------------------------------------------------- self.sect_left = Frame(master) self.sect_left.place(x=15, y=15, width=self.sect_width, height=570) self.sect_left.config(relief=RIDGE) self.sect_left.config(background=self.gray2) # RIGHT SECTION LAYER # -------------------------------------------------------------------- self.sect_right = Frame(master) self.sect_right.place(x=-15, y=200, width=self.sect_width, height=385) self.sect_right.place(relx=1.0, anchor="ne") self.sect_right.config(relief=RIDGE) self.sect_right.config(background=self.gray2) # Sliders layer self.layer_sliders = Frame(self.sect_left) self.layer_sliders.place(y=0, width=self.sect_width, height=320) self.layer_sliders.config(**self.layer_props(self.gray2)) self.lab_sliders = Label(self.layer_sliders) self.lab_sliders.config(**self.title_props("Parameters")) self.lab_sliders.pack() # DOB layer self.layer_dob = Frame(self.sect_left) self.layer_dob.place(y=320, width=self.sect_width, height=80) self.layer_dob.config(**self.layer_props(self.gray2)) self.lab_dob = Label(self.layer_dob) self.lab_dob.config(**self.title_props("Birthdays range")) self.lab_dob.pack() # Export layer self.layer_export = Frame(self.sect_left) self.layer_export.place(y=400, width=self.sect_width, height=80) self.layer_export.config(**self.layer_props(self.gray2)) self.lab_export = Label(self.layer_export) self.lab_export.config(**self.title_props("Export format")) self.lab_export.pack() # Run layer self.layer_run = Frame(self.sect_left) self.layer_run.place(y=480, width=self.sect_width, height=100) self.layer_run.config(**self.layer_props(self.gray2)) self.lab_run = Label(self.layer_run) self.lab_run.config(**self.title_props("Run")) self.lab_run.pack() # About layer self.layer_about = Frame(self.sect_right) self.layer_about.place(width=self.sect_width, height=385) self.layer_about.config(**self.layer_props(self.gray2)) self.lab_about = Label(self.layer_about) self.lab_about.config(**self.title_props("About Red Snapper")) self.lab_about.pack() # sliders self.sli_wom = Scale(self.layer_sliders, from_=0, to=100) self.sli_wom.config(**self.sli_props()) self.sli_wom.config(label="Percentage of women in dataset.") self.sli_wom.pack(padx=20, pady=10) self.sli_wom.set(50) self.sli_nam = Scale(self.layer_sliders, from_=0, to=100) self.sli_nam.config(**self.sli_props()) self.sli_nam.config(label="Percentage of people with double name") self.sli_nam.pack(padx=20, pady=0) self.sli_nam.set(25) self.sli_sur = Scale(self.layer_sliders, from_=0, to=100) self.sli_sur.config(**self.sli_props()) self.sli_sur.config(label="Percentage of people with double surname") self.sli_sur.pack(padx=20, pady=10) self.sli_sur.set(15) # DOB Layer - From Date self.dob1_val.set("1945") self.lab_dob1 = Label(self.layer_dob, text="From date") self.lab_dob1.config(**self.label_props()) self.lab_dob1.pack(side=LEFT, padx=5) self.box_dob1 = Spinbox(self.layer_dob) self.box_dob1.config(from_=1945, to=1996, textvariable=self.dob1_val) self.box_dob1.config(**self.date_props()) self.box_dob1.pack(side=LEFT) # DOB Layer - To Date self.dob2_val.set("1997") self.lab_dob2 = Label(self.layer_dob, text="To date") self.lab_dob2.config(**self.label_props()) self.lab_dob2.pack(side=LEFT, padx=17) self.box_dob2 = Spinbox(self.layer_dob) self.box_dob2.config(from_=1946, to=1997, textvariable=self.dob2_val) self.box_dob2.config(**self.date_props()) self.box_dob2.pack(side=LEFT) # Export layer - JSON / CSV radio buttons self.rb_choice.set("CSV") self.rb1 = Radiobutton(self.layer_export, text="Save as CSV", variable=self.rb_choice, value="CSV") self.rb1.config(**self.radio_props()) self.rb1.place(y=35, x=50) self.rb2 = Radiobutton(self.layer_export, text="Save as JSON", variable=self.rb_choice, value="JSON") self.rb2.config(**self.radio_props()) self.rb2.place(y=35, x=200) # Run layer - no of records spinbox self.df_records.set("100") self.box_gen = Spinbox(self.layer_run) self.box_gen.config(from_=1, to=999999, textvariable=self.df_records) self.box_gen.config(increment=1000, width=19) self.box_gen.place(x=70, y=53) self.lab_gen = Label(self.layer_run, text="Number of records") self.lab_gen.config(**self.label_props()) self.lab_gen.place(x=70, y=30) # Run layer - generate button self.btn_run = ttk.Button(self.layer_run) self.btn_run.place(x=225, y=35, height=40) self.btn_run_reset() # header & logo section self.sect_logo = Frame(master) self.sect_logo.place(x=-15, y=30, width=350, height=120) self.sect_logo.place(relx=1.0, anchor="ne") self.logo = PhotoImage(file="./redsnapper/interface/logo.png") self.lab_logo = Label(self.sect_logo, image=self.logo) self.lab_logo.config(background=self.gray1) self.lab_logo.pack() # About box_about = Text(self.layer_about) box_about.config(**self.text_props()) box_about.pack(pady=10, padx=10) txt = """This program allows generating thousands of rows filled with pseudo-random data. """ \ + """\nThe generated records (like name, """ \ + """ surname, date of birth, e-mail address) can be used to provide sample data to: - test query performance of your database - practice data operations with BI tools.""" \ + """ \nThe application uses 4 processes to generate data simultaneously. """ \ + """ It takes about 25 seconds to create 1 million rows of data.\n""" box_about.insert(END, txt)
#!/usr/bin/env python3 ''' gui3.py tkinter sample for python3 training at jasaplus.com ''' from tkinter import Tk, Canvas, PhotoImage, Label window = Tk() window.title("3rd") window.geometry("600x400+300+10") C = Canvas(window, bg="white", height=600, width=400) filename = PhotoImage(file="images/bg.gif") background_label = Label(window, image=filename) background_label.place(x=0, y=0, relwidth=1, relheight=1) C.pack() window.mainloop()
pygame.mixer.init() pygame.mixer.music.load(playlist[i]) pygame.mixer.music.play() def prev(): global i i += 1 pygame.mixer.pre_init(44100, -16, 2, 1024) pygame.mixer.init() pygame.mixer.music.load(playlist[i]) pygame.mixer.music.play() #symbols to be displayed on button playImage = PhotoImage(file="./icons/play.png") nextImage = PhotoImage(file="./icons/next.png") prevImage = PhotoImage(file="./icons/priv.png") listImage = PhotoImage(file="./icons/list.png") exitImage = PhotoImage(file="./icons/exit.png") pauseImage = PhotoImage(file="./icons/pause.png") stopImage = PhotoImage(file="./icons/stop.png") pl = playImage.subsample(3, 3) ps = pauseImage.subsample(3, 3) nx = nextImage.subsample(3, 3) prv = prevImage.subsample(3, 3) lst = listImage.subsample(3, 3) pwr = exitImage.subsample(3, 3) st = stopImage.subsample(3, 3)
def __init__(self, parent) -> None: self.parent = parent del parent self.main_window: ClassVar = Toplevel(self.parent) self.disallowed_windows: list = [self.main_window.winfo_id()] # hide window self.main_window.withdraw() # window style self.main_window.configure(background='#212121') self.main_theme: ClassVar = ttk.Style() self.main_theme.theme_use('clam') self.main_theme.layout( 'debugger.TEntry', [('Entry.padding', { 'children': [('Entry.textarea', { 'sticky': 'nswe' })], 'sticky': 'nswe' })]) self.main_theme.configure('debugger.TEntry', background='#111', foreground='#fff', fieldbackground='#111', selectforeground='#fff', selectbackground='#333') self.main_theme.configure('debugger.small.TButton', background='#111', relief='flat', font=('Consolas', 9), foreground='#fff') self.main_theme.map('debugger.small.TButton', background=[('pressed', '!disabled', '#111'), ('active', '#151515')]) self.main_theme.configure('debugger.TButton', background='#111', relief='flat', font=('Consolas', 12), foreground='#fff') self.main_theme.map('debugger.TButton', background=[('pressed', '!disabled', '#111'), ('active', '#151515')]) self.main_theme.configure('debugger.Vertical.TScrollbar', gripcount=0, relief='flat', background='#333', darkcolor='#111', lightcolor='#111', troughcolor='#111', bordercolor='#111', arrowcolor='#333') self.main_theme.layout('debugger.Vertical.TScrollbar', [('Vertical.Scrollbar.trough', { 'children': [('Vertical.Scrollbar.thumb', { 'expand': '1', 'sticky': 'nswe' })], 'sticky': 'ns' })]) self.main_theme.map('debugger.Vertical.TScrollbar', background=[('pressed', '!disabled', '#313131'), ('disabled', '#111'), ('active', '#313131'), ('!active', '#333')]) # window attributes self.main_window.attributes("-topmost", True) self.main_window.title(f'DEBUGGING: {self.parent.title()}') # self.main_window.geometry('665x800') self.main_window.minsize(665, 500) self.main_window.protocol('WM_DELETE_WINDOW', self.close_debugger) # variables self.widget: ClassVar = None self.highlighted_elements: dict = {} self.inspecting: bool = False self.allow_self_debug = False self.blank_photo: ClassVar = PhotoImage(height=16, width=16) self.blank_photo.blank() self.main_window.iconphoto(False, self.blank_photo) # content top_frame: ClassVar = Frame(self.main_window, background=self.main_window['background']) # inspect button self.inspect_button: ClassVar = ttk.Button(top_frame, text='INSPECT ELEMENT', takefocus=False, style='debugger.TButton', command=self.toggle_inspect) self.inspect_button.pack(side='left', padx=(10, 0), pady=10) self.inspect_next_button: ClassVar = ttk.Button( top_frame, text='INSPECT NEXT', takefocus=False, style='debugger.TButton', command=self.inspect_next) self.inspect_next_button.state(['disabled']) self.inspect_next_button.pack(side='left', padx=(10, 0), pady=10) self.widgets_label: ClassVar = Label( top_frame, text=f'{len(self.get_all_widgets(self.parent))} WIDGETS', background='#111', foreground='#fff', font=('Consolas', 12)) self.widgets_label.pack(side='left', padx=(10, 0), pady=10, ipady=5, ipadx=5) self.refresh_button: ClassVar = ttk.Button( top_frame, text='REFRESH', takefocus=False, style='debugger.TButton', command=lambda: self.inspect_widget(self.widget)) self.refresh_button.state(['disabled']) self.refresh_button.pack(side='left', padx=(10, 0)) self.mode_label: ClassVar = Label(top_frame, text='NORMAL', background='#111', foreground='#fff', font=('Consolas', 12)) self.mode_label.pack(side='left', padx=10, ipady=5, ipadx=5) top_frame.pack(side='top', fill='x') mid_frame: ClassVar = Frame(self.main_window, background=self.main_window['background']) widget_frame: ClassVar = Frame(mid_frame, background='#333') Label(widget_frame, text='WIDGET CLASS, NAME', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) self.widget_name: ClassVar = Label(widget_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.widget_name.pack(side='top', fill='x', padx=5, pady=5) Label(widget_frame, text='WIDGET DIMENTIONS', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) self.widget_dimensions: ClassVar = Label(widget_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.widget_dimensions.pack(side='top', fill='x', padx=5, pady=5) Label(widget_frame, text='WIDGET MANAGER', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) self.widget_manager: ClassVar = Label(widget_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.widget_manager.pack(side='top', fill='x', padx=5, pady=5) Label(widget_frame, text='MANAGER CONFIG', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) self.manager_config: ClassVar = Label(widget_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.manager_config.pack(side='top', fill='x', padx=5, pady=5) Label(widget_frame, text='WIDGET PARENT', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) parent_frame: ClassVar = Frame(widget_frame, background=widget_frame['background']) self.widget_perent: ClassVar = Label(parent_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.widget_perent.pack(side='left', fill='x', expand=True) self.inspect_perent: ClassVar = ttk.Button( parent_frame, text='INSPECT', takefocus=False, style='debugger.small.TButton', command=lambda: self.inspect_widget( self.widget._nametowidget(self.widget.winfo_parent()))) self.inspect_perent.state(['disabled']) self.inspect_perent.pack(side='left', fill='x', padx=5) parent_frame.pack(side='top', fill='x', padx=5, pady=(5, 0)) Label(widget_frame, text='WIDGET BINDINGS', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) self.widget_bindings: ClassVar = Label(widget_frame, text='', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)) self.widget_bindings.pack(side='top', fill='x', padx=5, pady=5) Label(widget_frame, text='WIDGET PROPERTIES', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) properties_frame: ClassVar = Frame( widget_frame, background=widget_frame['background']) properties_text: ClassVar = Frame( properties_frame, background=properties_frame['background']) Label(properties_text, text='WIDGET TEXT:', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)).pack(side='left', fill='x') self.entry: ClassVar = ttk.Entry(properties_text, style='debugger.TEntry', font=('Consolas', 12)) self.entry.state(['disabled']) self.entry.pack(side='left', fill='x', ipady=2, expand=True, padx=(5, 0)) self.apply_button: ClassVar = ttk.Button( properties_text, text='APPLY', takefocus=False, style='debugger.small.TButton', command=self.apply_changes) self.apply_button.state(['disabled']) self.apply_button.pack(side='left', fill='x', padx=5) properties_text.pack(side='top', fill='x', pady=(0, 5)) properties_image: ClassVar = Frame( properties_frame, background=properties_frame['background']) Label(properties_image, text='WIDGET IMG:', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)).pack(side='left', fill='x') self.widget_image: ClassVar = ttk.Button( properties_image, text='OPEN IMAGE', takefocus=False, style='debugger.small.TButton', command=self.open_image) self.widget_image.state(['disabled']) self.widget_image.pack(side='left', fill='x', padx=5) properties_image.pack(side='top', fill='x', pady=(0, 5)) properties_function: ClassVar = Frame( properties_frame, background=properties_frame['background']) Label(properties_function, text='WIDGET FUNCTION:', background='#111', foreground='#fff', anchor='w', font=('Consolas', 12)).pack(side='left', fill='x') self.widget_function: ClassVar = ttk.Button( properties_function, text='CALL FUNCTION', takefocus=False, style='debugger.small.TButton', command=self.call_function) self.widget_function.state(['disabled']) self.widget_function.pack(side='left', fill='x', padx=5) properties_function.pack(side='top', fill='x') properties_frame.pack(side='top', fill='x', padx=5, pady=(5, 0)) Label(widget_frame, text='WIDGET CHILDRENS', background=widget_frame['background'], foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=5, pady=(5, 0)) canvas_frame: ClassVar = Frame(widget_frame, background=widget_frame['background']) scrollbar: ClassVar = ttk.Scrollbar( canvas_frame, style='debugger.Vertical.TScrollbar') self.canvas: ClassVar = Canvas(canvas_frame, borderwidth=0, highlightthickness=0, background='#111', yscrollcommand=scrollbar.set) scrollbar.configure(command=self.canvas.yview) self.canvas_cards: ClassVar = Frame( self.canvas, background=self.canvas['background']) self.canvas_cards.bind( '<Configure>', lambda _: self.canvas.configure(scrollregion=self. canvas.bbox('all'))) self.canvas_window: ClassVar = self.canvas.create_window( (0, 0), window=self.canvas_cards, anchor='nw') self.canvas.bind( '<Configure>', lambda _: self.canvas.itemconfigure( self.canvas_window, width=self.canvas.winfo_width(), height=len(self.canvas_cards.winfo_children()) * 51)) self.canvas.pack(side='left', fill='both', expand=True, padx=10, pady=10) scrollbar.pack(side='right', fill='y', pady=10, padx=(0, 10)) canvas_frame.pack(side='top', fill='both', expand=True) widget_frame.pack(side='top', fill='both', expand=True, padx=10) mid_frame.pack(side='top', fill='both', expand=True) Label(self.main_window, text='DEBUGGER BY MATEUSZ PERCZAK (Łosiek)', background='#111', foreground='#fff', font=('Consolas', 12), anchor='w').pack(side='top', fill='x', padx=10, pady=(10, 0)) # show window self.main_window.bind('<MouseWheel>', self.on_mouse) self.entry.bind('<KeyRelease>', self.entry_diff) self.main_window.after(100, self.init_img_window) self.main_window.after(150, lambda: self.inspect_widget(self.parent)) self.check_bind_collisions() self.main_window.deiconify() self.show_window() self.main_window.mainloop()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) photo = PhotoImage(file=resource_path("white.gif")) photolab = Label(self, image=photo) photolab.image = photo photolab.grid(row=0, column=2, columnspan=2, rowspan=4, sticky='nwes')
#update the toolbar global toolbar #toolbar = NavigationToolbar2Tk(canvas, toolbarframe) #toolbar.grid(row = 0, column = 2, sticky = W) toolbar.update() #say the figure has loaded root.title('SpecTr - ' + folder) #make the SpecTr toolbar spectrtoolbar = Frame(root) spectrtoolbar.grid(row=0, column=0, sticky=W, pady=2, padx=2) #make the open button openimage = PhotoImage(file='Images/open.gif') openbutton = Button(spectrtoolbar, text='Open', image=openimage, command=browse) openbutton.grid(row=0, column=0, sticky=W) #make the process button processimage = PhotoImage(file='Images/process.gif') processbutton = Button(spectrtoolbar, text='Process', image=processimage, command=process, state=DISABLED) processbutton.grid(row=0, column=1, sticky=W)
'pressed', 'readonly', 'selected' ] # Create rasio buttons which will display widget states state_val = StringVar() for iy, state in enumerate(states): st_rb = Radiobutton(fr, value=state, text=state, variable=state_val, command=change_state) st_rb.grid(column=0, row=iy, padx=5, pady=5, sticky='nw') direct = ('up', 'down', 'left', 'right') img1 = PhotoImage("trough-horiz", file='../images/piratz/trough-horiz.png') img2 = PhotoImage("trough-vert", file='../images/piratz/trough-vert.png') img3 = PhotoImage("slider-hn", file='../images/piratz/slider-hn.png') img4 = PhotoImage("slider-vn", file='../images/piratz/slider-vn.png') img5 = PhotoImage("slider-hd", file='../images/piratz/slider-hd.png') img6 = PhotoImage("slider-vd", file='../images/piratz/slider-vd.png') img7 = PhotoImage("slider-ha", file='../images/piratz/slider-ha.png') img8 = PhotoImage("slider-va", file='../images/piratz/slider-va.png') img9 = PhotoImage("arrowup-a", file='../images/piratz/arrowup-a.png') img10 = PhotoImage("arrowup-d", file='../images/piratz/arrowup-d.png') img11 = PhotoImage("arrowup-n", file='../images/piratz/arrowup-n.png') img12 = PhotoImage("arrowup-p", file='../images/piratz/arrowup-p.png') img13 = PhotoImage("arrowdown-a", file='../images/piratz/arrowdown-a.png') img14 = PhotoImage("arrowdown-d", file='../images/piratz/arrowdown-d.png') img15 = PhotoImage("arrowdown-n", file='../images/piratz/arrowdown-n.png') img16 = PhotoImage("arrowdown-p", file='../images/piratz/arrowdown-p.png')
def __init__(self, canvas, board, width, graphics, col, row): '''Initialises the player and its attributes''' self.canvas = canvas self.start_col = col self.start_row = row self.players.append(self) self.player_number = len(self.players) self.board = board self.graphics = graphics self.width = width self.player_size = width/5 self.direction = 'up' self.v_vector = [0,0] self.key_pressed=False self.rocks_dict = graphics.rocks self.regular_dict = graphics.regular self.absolute_dict = graphics.absolute self.pause=False self.round_ended=False self.paused_time = 0 self.round_time = 0 self.dead = False self.afters = [] self.points = 0 self.fire = {} self.fire_counter = 0 for i in ITEMS: Player.items[i]={} self.power = 2 self.num_bombs = 1 self.bombs_placed = 0 self.time = 0 #bomb images self.bombdrop0 = ImageTk.PhotoImage(file='png/bombdrop0.png') self.bomb_images = [ImageTk.PhotoImage(file='png/bombdrop0.png'), ImageTk.PhotoImage(file='png/bombdrop1.png'), ImageTk.PhotoImage(file='png/bombdrop2.png')] #player images self.positions = ['forw','back','right','left'] self.position = None#'forw' self.player_images = {} for position in self.positions: images_of_position = [] for i in range(3): images_of_position.append(ImageTk.PhotoImage( file='png/'+str(self.player_number)+position+str(i)+'.png')) self.player_images[position] = images_of_position #dead images self.death_images = [] for i in range(8): self.death_images.append(ImageTk.PhotoImage( file='png/'+str(self.player_number)+'dead'+str(i)+'.png')) #soft block images self.soft_block_images = [] for i in range(1,6): self.soft_block_images.append( ImageTk.PhotoImage(file='png/softblock'+str(i)+'.png')) #fire images self.fire_images={} fire_text = ['hor','vert','mid','top','bot','left','right'] for text in fire_text: self.fire_images[text]=[] num_images=4 if text == 'mid': num_images=5 for num in range(num_images): self.fire_images[text].append( ImageTk.PhotoImage(file='fire/'+text+str(num)+'.png')) #scoreboard self.graphics.create_player_score(self.players.index(self)) #images self.images = {} for i in ITEMS: self.images[i]=[] self.images[i].append(PhotoImage(file='gifs/'+i+'0.gif')) self.images[i].append(PhotoImage(file='gifs/'+i+'1.gif')) hobo = ImageTk.PhotoImage(file='png/'+str(self.player_number)+'forw0.png') l = Label(image=hobo) l.image = hobo # keep a reference! doesnt work without left, top, right, bot = self.canvas.coords(self.regular_dict[(col,row)]) self.player = self.canvas.create_rectangle( left, top, right, bot, fill='white') self.canvas.itemconfig(self.player, state='hidden') self.player_image = self.canvas.create_image( (left+right)/2,(top+bot)/2-4, image=self.player_images['forw'][0]) self.animate_player() self.movement()
# Declare modules used in the program from tkinter import Tk, PhotoImage, Label, Button from modules import * ### MAIN GUI TRIGGERS AND FUNCTIONS FOR THE TOOL ### if __name__ == "__main__" : main = Tk() main.title("SBI : Explainable ML, Logistic Regression") #frame = tkinter.Frame(main, width = 100, height = 10).pack() logo = PhotoImage(file="../data/sbi2.png") l1 = Label(main, image = logo).pack(side = "top") text = "Explainable ML toolkit. Train a model for your dataset, explain feature contribution for each ." l2 = Label(main, text = text).pack(side = "top") print("Train a model by uploading training data!\nExplain a trained model") w0 = Button(main, text = "Train a logistic regression model", width = 25, command = trainModel) w1 = Button(main, text = "Explain model", width = 25, command = explain) w2 = Button(main, text = "Use Lime to analyze model", width = 25, command = lime) w3 = Button(main, text = "Exit", width = 25, command = exit_) w3.pack(side = "bottom") w2.pack(side = "bottom") w1.pack(side = "bottom") w0.pack(side = "bottom") main.mainloop()
def paste(): content_text.event_generate("<<Paste>>") return "break" def undo(): content_text.event_generate("<<Undo>>") return "break" def redo(event=None): content_text.event_generate("<<Redo>>") return 'break' new_file_icon = PhotoImage(file='icons/new_file.gif') open_file_icon = PhotoImage(file='icons/open_file.gif') save_file_icon = PhotoImage(file='icons/save.gif') cut_icon = PhotoImage(file='icons/cut.gif') copy_icon = PhotoImage(file='icons/copy.gif') paste_icon = PhotoImage(file='icons/paste.gif') undo_icon = PhotoImage(file='icons/undo.gif') redo_icon = PhotoImage(file='icons/redo.gif') menu_bar = Menu(root) file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label='New', accelerator='Ctrl+N', compound='left', image=new_file_icon, underline=0, command=new_file) file_menu.add_command(label='Open', accelerator='Ctrl+O', compound='left', image=open_file_icon, underline=0, command=open_file) file_menu.add_command(label='Save', accelerator='Ctrl+S',
note.add(rescipt, text="RESCIPT") ############## food tab ############### for b in range(len(i)): food1 = tk.Frame(food, cnf=bgak) food1.grid(row=b, column=0, sticky=tk.E + tk.W) name = i["1"]["name"] tk.Label(food1, text=name, cnf=bgak1).grid(row=0, column=0, pady=5, padx=5) rating = i["1"]["rating"] * "★" + "(" + str(i["1"]["review"]) + ")" tk.Label(food1, text=rating, cnf=bgak2).grid(row=1, column=0, pady=5) price = str(i["1"]["price"]) + "$" tk.Label(food1, text=price, cnf=bgak3).grid(row=2, column=0, pady=5) img = PhotoImage(file=i["1"]["img"]).subsample(2) tk.Label(food1, image=img).grid(row=0, column=1, rowspan=3) tk.Label(food1, text=i[b]["count"], font=("times", 15), bg="#ffc107").grid(row=0, column=1, sticky=tk.S) tk.Button(food1, text="+", cammand=lambda x=str(b): cnt("+", x)).grid(row=0, column=2) tk.Button(food1, text="-", cammand=lambda y=str(b): cnt("-", y)).grid(row=0, column=3) ###################################### for s in range(len(d)): food1 = tk.Frame(drinks, cnf=bgak) food1.grid(row=s, column=0, sticky=tk.E + tk.W) name = d[s]["name"]
from tkinter import Tk, scrolledtext, Menu, filedialog, END, messagebox, simpledialog, Text, PhotoImage, Wm, Image from pathlib import Path import os from functools import partial # Root for Main Window root = Tk(className='Text Editor') textArea = scrolledtext.ScrolledText(root, width=100, height=80, undo=True, maxundo=-1, fg="black") #Setting Icon iconpath = Path.cwd() / 'icons' / 'te.gif' ticon = Image('photo', file=str(iconpath)) icon = PhotoImage(str(iconpath)) root.tk.call('wm', 'iconphoto', root._w, ticon) prevFile = None # Functions def newFile(): if len(textArea.get('1.0', END + '-1c')) > 0: if messagebox.askyesno("Save?", "Do you wish to save?"): saveFile() fileSaved = True if fileSaved == True: textArea.delete('1.0', END) fileSaved = False else: textArea.delete('1.0', END)
myWindow = Tk() myWindow.title('Space Invaders') myWindow.geometry('800x500') labelScore = Label(myWindow, text="Score : ") labelScore.config(text='Score : ' + '0') labelScore.grid(row=0, column=0) #labelScore.pack(side= 'top') labelLives = Label(myWindow) labelLives.config(text='Lives : ' + '3') labelLives.grid(row=0, column=1) #labelLives.pack(side= 'top') photo = PhotoImage(file="terre.gif") photo1 = PhotoImage(file="game_over.gif") photo2 = PhotoImage(file="logo.gif") photo3 = PhotoImage(file="won.gif") largeur = 700 hauteur = 445 monCanvas = Canvas(myWindow, width=largeur, height=hauteur) # a ameliorer pour ne pas repeter la fonction 3 fois, mais si je met le photo = PhotoImage(file = ... dans la fonction ca ne marche pas def creerImageFond(): monCanvas.create_image(0, 0, anchor='nw', image=photo) def creerImageGameOver(): monCanvas.create_image(0, 0, anchor='nw', image=photo1)
def __init__(self, master): super().__init__(master) self.welcome = ttk.Label( self, text="Welcome To Election Commission of Pakistan") self.welcome.config(foreground='white', background='green', font=('Times new roman', 49, 'bold')) self.welcome.pack(side=TOP) self.localtime = time.asctime(time.localtime(time.time())) self.lbl1 = Label(self, font=('times new roman', 10), text=self.localtime, fg="black", bd=10, bg="light green") self.lbl1.pack(padx=3, fill=X) self.f1 = Frame(self, width=999, height=700, bg="light green", relief=SUNKEN) self.f1.pack(side=RIGHT) self.filename = PhotoImage( file= "C:\\Users\\atikul saikh\\Downloads\\PROJECT FINAL changes\\5new.png" ) self.background_label = Label(self.f1, image=self.filename) self.background_label.place(bordermode=OUTSIDE, height=550, width=999) self.f2 = Frame(self, width=300, height=700, bg="WHITE", relief=SUNKEN) self.f2.pack(side=LEFT) self.T = Text(self.f2, height=3, width=30, fg="green") self.T.pack(padx=5) self.T.insert( END, "Welcome!\nProvide your logins to access \nmore features....!\n\n\n" ) self.label_1 = Label(self.f2, font=('times new roman', 15), text="Username", bg="green", fg="white") self.label_1.pack(fill=X, padx=15) self.E1 = Entry(self.f2, bd=5) self.E1.pack(fill=X, padx=15) self.label_2 = Label(self.f2, font=('times new roman', 15), text="Password", bg="green", fg="white") self.label_2.pack(fill=X, padx=15) self.E2 = Entry(self.f2, bd=5, show="*") self.E2.pack(fill=X, padx=15) def login(): username = self.E1.get() password = self.E2.get() if username == "admin" and password == "admin": self.newWindow = Toplevel(self.master) self.app = Home(self.newWindow) elif username == "" or password == "": tm.showerror("Login error", "Please Enter Username and Password", parent=root) else: tm.showerror("Login error", "Incorrect username or password", parent=root) self.b1 = Button(self.f2, font=('times new roman', 10), padx=5, pady=5, bd=5, fg="white", text="login", bg="green", height=1, width=5, command=login) self.b1.pack() self.pack()