Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.ttk as ttk
- import locale
- locale.setlocale(locale.LC_ALL, 'en_US') #sets locale to US for number formatting
- #universal background, text, button background, button text color
- uni_bg = "gray6"
- uni_fg = "gray90"
- uni_bt_bg = "gray35"
- uni_bt_fg = "black"
- uni_bt_active = "gray45"
- uni_font = "fixedsys"
- #formats seconds to minutes and seconds
- def get_shortet(seconds):
- minutes = seconds // 60
- if minutes < 10:
- minutes = "0" + str(minutes)
- seconds = seconds % 60
- if seconds < 10:
- seconds = "0" + str(seconds)
- return "%s:%s" % (minutes, seconds)
- class MainWin(Tk):
- def __init__(self, master):
- self.master = master
- master.title("Main Menu")
- master.geometry("800x500")
- master.configure(background = uni_bg)
- self.mission_list = ["1", "2", "3"]
- self.response_list = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "This is a really long piece of text to see if wrapping works correctly"]
- self.lbl = Label(root, text = "The Guy in the Chair", font = (uni_font, 24), bg = uni_bg, fg = uni_fg)
- self.lbl.grid(column = 0, row = 0, pady = 10, columnspan = 2)
- self.mission_frame = Frame(self.master, bd = 10, bg = uni_bg)
- self.mission_frame.grid(column = 1, row = 1, sticky = "n")
- self.response_frame = Frame(self.master, bd = 10, bg = uni_bg)
- self.response_frame.grid(column = 0, row = 1)
- self.response = Text(self.response_frame, font = (uni_font, 12), bd = 10, height = 10, width = 50, wrap = WORD)
- self.response.grid(column = 0)
- self.response.delete(1.0 , END)
- for item in self.response_list:
- self.response.insert(END, item + '\n')
- self.response.see("end")
- entry_box = Entry(self.master, width = 70)
- entry_box.grid(column = 0, row = 2, sticky = "w", padx = 10)
- entry_box.bind('<Return>', self.enter_key)
- self.combo1 = ttk.Combobox(self.mission_frame, state = "readonly", font = (uni_font, 12), width = 35)
- root.option_add('*TCombobox*Listbox.font', uni_font)
- self.combo1.grid()
- self.combo1.bind("<<ComboboxSelected>>", self.mission_select)
- self.combo1['values'] = self.mission_list
- def mission_select(self, event):
- self.master.focus_set()
- def enter_key(self, event = None):
- input_txt = self.entry_box.get()
- self.response_list.append(input_txt)
- self.response.delete(1.0 , END)
- for item in self.response_list:
- self.response.insert(END, item + '\n')
- self.response.see("end")
- root = Tk()
- mainwin = MainWin(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement