예제 #1
0
 def mini_screen(self):
     """Secondary window for result information"""
     # noinspection PyAttributeOutsideInit
     self.master_2 = Tk()
     # noinspection PyAttributeOutsideInit
     frame = Frame(self.master_2,
                   bg=st.color['fg'],
                   highlightbackground=st.color['fg_enter'],
                   highlightcolor=st.color['fg_enter'],
                   highlightthickness=3)
     if self.rem < 1440:
         x, y = 400, 500
     else:
         x, y = 700, 700
     self.master_2.geometry('{}x{}+{}+{}'.format(
         x, y, int(self.master.winfo_screenwidth() // 2 - x / 2),
         int(self.master.winfo_screenheight() // 2 - y / 2)))
     self.master_2.overrideredirect(True)
     self.master_2.update_idletasks()
     frame.pack(fill=BOTH, expand=True)
     niv = None
     if self.level_status == 1:
         niv = st.L_EN[2]
     if self.level_status == 2:
         niv = st.L_EN[1]
     if self.level_status == 3:
         niv = st.L_EN[0]
     text = st.P_EN['won'].format(niv.capitalize(), self.secret_word.get(),
                                  self.total, '')
     fg = 'green'
     bg = st.color['fg']
     if len(self.misses) == 7 or not self.time_left.get():
         text = st.P_EN['lose']
         fg = 'red'
     # noinspection PyAttributeOutsideInit
     label = Label(frame,
                   text=text,
                   bg=bg,
                   fg=fg,
                   justify=LEFT,
                   font=st.font(self.rem, 5))
     ok = Button(frame,
                 bg=st.color['fg'],
                 bd=0,
                 fg=st.color['fg_enter'],
                 font=st.font(self.rem, 3),
                 text='Ok',
                 command=lambda: self.master_2.destroy(),
                 activeforeground='black',
                 activebackground=st.color['fg'],
                 width=2)
     label.pack(fill=BOTH, expand=True)
     ok.place(relx=0.5, rely=0.96, anchor='s')
예제 #2
0
 def category_buttons(self):
     """Word category buttons"""
     r, c, bg, s = 0, 0, st.color['bg_cat_a'], NORMAL
     for item in st.EN:
         if item == 'random':
             bg = st.color['fg']
             s = DISABLED
         b = Button(self.row_3_grid,
                    text='%s' % item.capitalize(),
                    bg=bg,
                    fg=st.color['fg_cat'],
                    font=st.font(self.rem, 8),
                    command=lambda i=item: self.set_category(i),
                    overrelief=SUNKEN,
                    anchor=CENTER,
                    bd=0,
                    state=s,
                    disabledforeground=st.color['bg'],
                    activeforeground=st.color['fg_cat'],
                    activebackground=st.color['bg_cat_a'],
                    width=1)
         if c == 4:
             r += 1
             c = 0
         b.grid(row=r, column=c, sticky='news', padx=15, pady=10)
         self.category.append(b)
         c += 1
예제 #3
0
 def abc_buttons(self):
     """Creates the alphabet buttons"""
     # noinspection PyAttributeOutsideInit
     r, c = 0, 0
     for item in st.ALPHABET:
         b = Button(
             self.row_1_grid,
             text='%s' % item,
             bg=st.color['bg'],
             fg=st.color['fg_abc'],
             font=st.font(self.rem, 1),
             command=lambda i=item: self.set_abc(i),
             justify='center',
             overrelief=SUNKEN,
             anchor=CENTER,
             bd=0,
             state=DISABLED,
             disabledforeground=st.color['dfg_abc'],
             activeforeground=st.color['afg_abc'],
             activebackground=st.color['abg_abc'],
         )
         if c == 13:
             r += 1
             c = 0
         b.grid(row=r, column=c, sticky='news', padx=7, pady=6)
         self.abc.append(b)
         c += 1
예제 #4
0
 def build_timer(self, *args):
     """Timer label"""
     b, f = st.set_buttons_color('timer', 1)
     # noinspection PyAttributeOutsideInit
     self.timer = Label(self.row_0_column_2,
                        text=self.timer_text.get(),
                        bg=b,
                        fg=f,
                        font=st.font(self.rem, 14))
     self.timer.grid(row=1, column=0, rowspan=2, sticky='nsew')
예제 #5
0
 def build_welcome_label(self, *args):
     """Word categories label"""
     bg, fg = st.set_buttons_color('title', 1)
     title = Label(self.welcome,
                   text='Guess Letters',
                   bg=bg,
                   fg=fg,
                   font=st.font(self.rem, 24),
                   justify=CENTER)
     title.pack(side=TOP, padx=20, pady=50)
예제 #6
0
 def score_screen(self):
     """Score screen"""
     # noinspection PyAttributeOutsideInit
     self.master_3 = Tk()
     # noinspection PyAttributeOutsideInit
     self.frame = Frame(self.master_3,
                        bg=st.color['fg'],
                        highlightbackground=st.color['fg_enter'],
                        highlightcolor=st.color['fg_enter'],
                        highlightthickness=3)
     if self.rem < 1440:
         x, y = 450, 500
     else:
         x, y = 600, 700
     self.master_3.geometry('{}x{}+{}+{}'.format(
         x, y, int(self.master.winfo_screenwidth() // 2 - x / 2),
         int(self.master.winfo_screenheight() // 2 - y / 2)))
     self.master_3.overrideredirect(True)
     self.master_3.update_idletasks()
     self.frame.pack(fill=BOTH, expand=True)
     text = 'Level \t  Points\t\tTime\n' + 37 * '_' + '\n'
     for item in rc.search():
         text += '{}\t   {}     {}\n'.format(
             item.level, item.points,
             item.timestamp.strftime(' %B %d, %Y %I:%M %p'))
     label = Label(self.frame,
                   text=text,
                   bg=st.color['bg'],
                   fg=st.color['fg'],
                   justify=LEFT,
                   font=st.font(self.rem, 0))
     ok = Button(self.frame,
                 bg=st.color['bg'],
                 bd=0,
                 fg=st.color['fg_enter'],
                 font=st.font(self.rem, 3),
                 text='Ok',
                 command=lambda: self.master_3.destroy(),
                 activeforeground='black',
                 activebackground=st.color['fg'],
                 width=2)
     label.pack(fill=BOTH, expand=True)
     ok.place(relx=0.5, rely=0.96, anchor='s')
예제 #7
0
 def build_clock_label(self, *args):
     """Main clock label"""
     bg, fg = st.set_buttons_color('points', 1)
     # noinspection PyAttributeOutsideInit
     self.clock = Label(self.row_0_column_2,
                        textvariable=self.clock_text,
                        bg=bg,
                        fg=fg,
                        font=st.font(self.rem, 0),
                        bd=0,
                        width=2)
     self.clock.grid(row=0, column=0, sticky='news', padx=0, pady=0)
예제 #8
0
 def build_score_label(self, *args):
     """Word categories label"""
     bg, fg = st.set_buttons_color('points', 1)
     points = Label(self.row_0_column_1,
                    text='Points:',
                    bg=bg,
                    fg=fg,
                    font=st.font(self.rem, -4, style='normal'),
                    bd=0,
                    width=2)
     points.grid(row=0, column=0, sticky='news', padx=0, pady=0)
     b, f = st.set_buttons_color('score', 1)
     score = Label(self.row_0_column_1,
                   textvariable=self.score_text,
                   bg=b,
                   fg=f,
                   font=st.font(self.rem, 0),
                   justify=CENTER,
                   bd=0,
                   width=2)
     score.grid(row=1, column=0, sticky='news', padx=0, pady=0)
예제 #9
0
 def build_word_label(self, *args):
     """Secret word label"""
     bg, fg = st.set_buttons_color('word', 1)
     # noinspection PyAttributeOutsideInit
     self.secret_word_label = Label(self.row_2_grid,
                                    textvariable=self.word_text,
                                    bg=bg,
                                    fg=fg,
                                    justify=RIGHT,
                                    font=st.font(self.rem, 16),
                                    anchor='e')
     self.secret_word_label.grid(row=0,
                                 column=1,
                                 sticky='nse',
                                 padx=20,
                                 pady=5)
예제 #10
0
 def build_title_label(self, *args):
     """Word categories label"""
     bg, fg = st.set_buttons_color('title', 1)
     title = Label(self.row_0_grid,
                   text=self.banner_text.get(),
                   bg=bg,
                   fg=fg,
                   font=st.font(self.rem, 10),
                   width=6)
     title.grid(row=0,
                column=5,
                rowspan=2,
                columnspan=10,
                sticky='ew',
                padx=5,
                pady=2)
예제 #11
0
 def buttons(self):
     """Info, check buttons"""
     close = st.image('quit')
     info = st.image('info')
     rule = st.image('rule')
     # noinspection PyAttributeOutsideInit
     self.start = self.create_button(self.row_0_grid, 'start')
     self.start.config(width=2, font=st.font(self.rem, -2))
     self.start.grid(row=0, column=0, sticky='news', padx=20, pady=7)
     # noinspection PyAttributeOutsideInit
     self.stop = self.create_button(self.row_0_grid, 'stop')
     self.stop.config(state=DISABLED, width=2, font=st.font(self.rem, -2))
     self.stop.grid(row=1, column=0, sticky='news', padx=20, pady=7)
     # noinspection PyAttributeOutsideInit
     self.quit = self.create_button(self.master, 'exit')
     self.quit.config(font=st.font(self.rem, 1), image=close)
     self.quit.image = close
     self.quit.place(relx=0.99, rely=0.01, anchor='ne')
     # noinspection PyAttributeOutsideInit
     self.score = self.create_button(self.row_0_column_1, 'high score')
     self.score.config(font=st.font(self.rem, -2, style='normal'),
                       overrelief=None,
                       relief=SOLID,
                       bd=0,
                       command=lambda: self.score_screen())
     self.score.grid(row=5, column=0, sticky='news')
     # noinspection PyAttributeOutsideInit
     self.info = self.create_button(self.welcome, 'info')
     self.info.config(
         font=st.font(self.rem, 0),
         command=lambda: st.set_rules('Game Info', st.prompt['Game Info']),
         image=info)
     self.info.image = info
     self.info.place(relx=0.01, rely=0.01, anchor='nw')
     # noinspection PyAttributeOutsideInit
     self.rule = self.create_button(self.welcome, 'rules')
     self.rule.config(font=st.font(self.rem, 0),
                      command=lambda: st.set_rules('Game Rules', st.prompt[
                          'Game Rules']),
                      image=rule)
     self.rule.image = rule
     self.rule.place(relx=0.01, rely=0.1, anchor='nw')
     # noinspection PyAttributeOutsideInit
     self.go = self.create_button(self.welcome, 'ENTER')
     self.go.config(font=st.font(self.rem, 16, family='Verdana'),
                    text='ENTER')
     self.go.pack(side=BOTTOM, expand=False, padx=5, pady=60)
     back = st.image('back')
     # noinspection PyAttributeOutsideInit
     self.back = self.create_button(self.row_0_grid, 'Back')
     self.back.config(font=st.font(self.rem, 1), image=back)
     self.back.image = back
     self.back.place(relx=0.99, rely=0.42, x=0, y=0, anchor='se')
     r, s, bg = 0, NORMAL, st.color['bg_level']
     for item in st.L_EN:
         b = self.create_button(self.row_0_column_3, item)
         if item == 'easy':
             s = DISABLED
             bg = st.color['fg']
         b.config(state=s,
                  font=st.font(self.rem, -4, style='bold'),
                  command=lambda i=item: self.set_level(i),
                  bg=bg)
         b.grid(row=r, column=0, sticky='news', pady=3)
         self.level.append(b)
         r += 1