Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.48 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.ttk as ttk
  3. import locale
  4. locale.setlocale(locale.LC_ALL, 'en_US') #sets locale to US for number formatting
  5.  
  6. #universal background, text, button background, button text color
  7. uni_bg = "gray6"
  8. uni_fg = "gray90"
  9. uni_bt_bg = "gray35"
  10. uni_bt_fg = "black"
  11. uni_bt_active = "gray45"
  12. uni_font = "fixedsys"
  13.  
  14. #formats seconds to minutes and seconds
  15. def get_shortet(seconds):  
  16.     minutes = seconds // 60
  17.     if minutes < 10:
  18.         minutes = "0" + str(minutes)
  19.        
  20.     seconds = seconds % 60
  21.     if seconds < 10:
  22.         seconds = "0" + str(seconds)
  23.    
  24.     return "%s:%s" % (minutes, seconds)
  25.  
  26. class MainWin(Tk):
  27.     def __init__(self, master):
  28.         self.master = master
  29.         master.title("Main Menu")
  30.         master.geometry("800x500")
  31.         master.configure(background = uni_bg)
  32.        
  33.         self.mission_list = ["1", "2", "3"]
  34.         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"]
  35.        
  36.         self.lbl = Label(root, text = "The Guy in the Chair", font = (uni_font, 24), bg = uni_bg, fg = uni_fg)
  37.         self.lbl.grid(column = 0, row = 0, pady = 10, columnspan = 2)
  38.        
  39.         self.mission_frame = Frame(self.master, bd = 10, bg = uni_bg)
  40.         self.mission_frame.grid(column = 1, row = 1, sticky = "n")
  41.        
  42.         self.response_frame = Frame(self.master, bd = 10, bg = uni_bg)
  43.         self.response_frame.grid(column = 0, row = 1)
  44.        
  45.         self.response = Text(self.response_frame, font = (uni_font, 12), bd = 10, height = 10, width = 50, wrap = WORD)
  46.         self.response.grid(column = 0)
  47.         self.response.delete(1.0 , END)
  48.         for item in self.response_list:
  49.             self.response.insert(END, item + '\n')
  50.         self.response.see("end")
  51.        
  52.         entry_box = Entry(self.master, width = 70)
  53.         entry_box.grid(column = 0, row = 2, sticky = "w", padx = 10)
  54.         entry_box.bind('<Return>', self.enter_key)
  55.        
  56.         self.combo1 = ttk.Combobox(self.mission_frame, state = "readonly", font = (uni_font, 12), width = 35)
  57.         root.option_add('*TCombobox*Listbox.font', uni_font)
  58.         self.combo1.grid()
  59.         self.combo1.bind("<<ComboboxSelected>>", self.mission_select)
  60.         self.combo1['values'] = self.mission_list
  61.            
  62.     def mission_select(self, event):
  63.         self.master.focus_set()
  64.        
  65.     def enter_key(self, event = None):
  66.         input_txt = self.entry_box.get()
  67.         self.response_list.append(input_txt)
  68.         self.response.delete(1.0 , END)
  69.         for item in self.response_list:
  70.             self.response.insert(END, item + '\n')
  71.         self.response.see("end")
  72.  
  73.  
  74. root = Tk()
  75. mainwin = MainWin(root)
  76. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement