def login(self): self.login_dialog = Toplevel() self.login_dialog.geometry("400x300") self.login_dialog.focus_force() self.login_dialog.attributes('-topmost', 'true') self.root.attributes('-disabled', 'true') LoginFrame(root=self.login_dialog, parent=self, data=self.flower_shop)
def init_gui(self): """Create the screens""" self.login_frame = LoginFrame(self) self.login_frame.pack() self.start_frame = StartFrame(self) self.results_frame = ResultsFrame(self) self.list_editor = ListEditor(self) self.mainloop()
def __init__(self): # init main window tk.Tk.__init__(self) self.lokr_file = '' self.user_file = '.lokrdata/usrs.ulokr' self.user = '' self.wm_iconbitmap( self, default=self.resource_path('assets\\closedlock.ico')) self.logo = tk.PhotoImage(file=self.resource_path('assets\\lock.png')) self.title('LOKR LOGIN') self.minsize(350, 200) plain_text_file = open('.lokrdata/cset.dlokr', 'rb') cipher_text_file = open('.lokrdata/cpcset.dlokr', 'rb') plain_text = pickle.load(plain_text_file) cipher_text = pickle.load(cipher_text_file) plain_text_file.close() cipher_text_file.close() self.crypt = Crypt(cipher_text, plain_text) LoginFrame(self) self.mainloop()
def __init__(self): # init main window tk.Tk.__init__(self) self.lokr_file = "" self.user_file = self.resource_path(".lokrdata/usrs.ulokr") self.user = "" self.iconbitmap(self.resource_path("assets/closedlock.ico")) self.logo = tk.PhotoImage(file=self.resource_path("assets/lock.png")) self.title("LOKR LOGIN") self.minsize(350, 200) plain_text_file = open(self.resource_path(".lokrdata/cset.dlokr"), "rb") cipher_text_file = open(self.resource_path(".lokrdata/cpcset.dlokr"), "rb") plain_text = pickle.load(plain_text_file) cipher_text = pickle.load(cipher_text_file) plain_text_file.close() cipher_text_file.close() self.crypt = Crypt(cipher_text, plain_text) LoginFrame(self) self.mainloop()
class SpellingGame(Tk): """Main class for spelling aid. Manages the other screens and holds festival and database connections""" def __init__(self): Tk.__init__(self) self.title('Spelling Game') #Estabilish database connection self.db = SpellingDatabase() #Get words from database self.word_list = self.get_dictionary() #Retrieve list of lists from db self.list_list = self.get_lists() #Start festival process self.festival = FestivalInterface() #Create screens self.init_gui() def get_lists(self): """Retrieve list of lists from database""" list_records = self.db.sql("""SELECT * FROM lists""") list_list = [] for wordlist in list_records: list_list.append(WordList(wordlist)) return list_list def update_lists(self): """Refresh the list-list""" self.list_list = self.get_lists() def get_dictionary(self): """Get dictionary words from database""" word_records = self.db.sql("""SELECT * FROM words WHERE difficulty LIKE 'SB%'""") word_list = [] for word in word_records: word_list.append(Word(word)) return word_list def get_random_list(self, length): """Return a random list of words""" words = random.sample(self.word_list, length) return words def login(self, user): """Show the start screen as user logs in""" self.user = user self.login_frame.pack_forget() self.start_frame.welcomeMessage() self.start_frame.pack() def start_game(self, word_list): """Hide start screen and show game screen. Retrieve words for selected list""" self.current_list = word_list if word_list.name != "Random List": word_records = self.db.getWords(word_list.name) self.current_list.words = [Word(word) for word in word_records] else: self.current_list.words = self.get_random_list(15) self.list_length = len(self.current_list.words) self.start_frame.pack_forget() self.results_frame.pack_forget() self.game_frame = GameFrame(self) self.game_frame.start() self.game_frame.pack() def show_results(self, time_elapsed): """Hide game frame and show results frame""" self.game_frame.pack_forget() self.results_frame.calculate(self.current_list, time_elapsed) self.results_frame.pack() def new_list(self): """Show start screen, hiding either results or list editor""" self.results_frame.pack_forget() self.list_editor.pack_forget() self.start_frame.update_list() self.start_frame.pack() def show_editor(self): """Hide start frame and show list editor""" self.start_frame.pack_forget() self.list_editor.pack() def init_gui(self): """Create the screens""" self.login_frame = LoginFrame(self) self.login_frame.pack() self.start_frame = StartFrame(self) self.results_frame = ResultsFrame(self) self.list_editor = ListEditor(self) self.mainloop()
def CreateFrame(self, type): if type == 0: return LoginFrame(parent=None, id=type, UpdateUI=self.UpdateUI) elif type == 2: return MainFrame(parent=None, id=type, UpdateUI=self.UpdateUI)
registerFrame.hide_frame() loginFrame.show_frame() newUserButton.grid() mainWindow = Tk() mainWindow.title("Python!!") mainWindow.geometry("250x300") mainWindow.configure(bg="Orange") topFrame = Frame(mainWindow, bg="Orange") topFrame.grid(row=0, column=0, sticky=W) newUserButton = Button(topFrame, text="New user", command=new_user_cmd) newUserButton.grid(row=0, column=0, sticky=W) getUserInfoButton = Button(topFrame, text="Get user information", command=user_info_cmd) getUserInfoButton.grid(row=0, column=1, sticky=W) mainFrame = Frame(mainWindow, bg="Orange") mainFrame.grid(row=1, column=0, sticky=W) loginFrame = LoginFrame(fileHandler, mainFrame) registerFrame = RegisterFrame(fileHandler, mainFrame) loginFrame.hide_frame() registerFrame.hide_frame() mainWindow.mainloop()
class SpellingGame(Tk): def __init__(self): Tk.__init__(self) self.title('Spelling Game') self.db = SpellingDatabase() self.word_list = self.get_dictionary() self.list_list = self.get_lists() self.festival = FestivalInterface() self.init_gui() def get_lists(self): list_records = self.db.sql("""SELECT * FROM lists""") list_list = [] for wordlist in list_records: list_list.append(WordList(wordlist)) return list_list def update_lists(self): self.list_list = self.get_lists() def get_dictionary(self): word_records = self.db.sql("""SELECT * FROM words WHERE difficulty LIKE 'SB%'""") word_list = [] for word in word_records: word_list.append(Word(word)) return word_list def get_random_list(self, length): words = random.sample(self.word_list, length) return words def login(self, user): self.user = user self.login_frame.pack_forget() self.start_frame.welcomeMessage() self.start_frame.pack() def start_game(self, word_list): self.current_list = word_list if word_list.name != "Random List": word_records = self.db.getWords(word_list.name) self.current_list.words = [Word(word) for word in word_records] else: self.current_list.words = self.get_random_list(15) self.list_length = len(self.current_list.words) self.start_frame.pack_forget() self.results_frame.pack_forget() self.game_frame = GameFrame(self) self.game_frame.start() self.game_frame.pack() def show_results(self, time_elapsed): self.game_frame.pack_forget() self.results_frame.calculate(self.current_list, time_elapsed) self.results_frame.pack() def new_list(self): self.results_frame.pack_forget() self.list_editor.pack_forget() self.start_frame.update_list() self.start_frame.pack() def show_editor(self): self.start_frame.pack_forget() self.list_editor.pack() def init_gui(self): self.login_frame = LoginFrame(self) self.login_frame.pack() self.start_frame = StartFrame(self) self.results_frame = ResultsFrame(self) self.list_editor = ListEditor(self) self.mainloop()
my_info = DeviceInfo('1', '1') thread = DeviceInfoThread() thread.start() comm = ThreadCommunication() comm.start() comm2 = ThreadFriendInfoCommunication() comm2.start() app = QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() main_ui = Ui_MainWindow(MainWindow) MainWindow.show() AddFriendDialog.AddFriendDialog.init(main_ui) LoginFrame.init() JoinFrame.init() WebChatFrame.init(MainWindow) FailDialog.init(MainWindow) sys.exit(app.exec_())