Exemple #1
0
 def colorize(self):
     formats = make_formats_dict()
     self.color1 = formats['head_bg'],
     self.color2 = formats['highlight_bg'],
     self.color3 = formats['bg']
     if self.height > 0:
         self.line1.config(bg=self.color1)
         self.line2.config(bg=self.color2)
         self.line3.config(bg=self.color3)
         self.line4.config(bg=self.color2)
         self.line5.config(bg=self.color1)
     else:
         self.line1.config(bg=self.color1)
         self.line2.config(bg=self.color2)
         self.line3.config(bg=self.color3)
    def __init__(self,
                 master,
                 size=3,
                 menubar=False,
                 ribbon_menu=False,
                 *args,
                 **kwargs):
        Canvas.__init__(self, master, *args, **kwargs)
        '''
            This class replaces root and dialog borders with custom borders. 

            Since this custom "Toykinter" border is part of the app instead 
            of being controlled by Windows, its use allows clicks on the title 
            bar to be responded to with standard Tkinter configuration methods 
            and other Python code. 

            This class can't use Toykinter as a master since Toykinter is the 
            whole app and is only instantiated once, so this class has to use 
            its host toplevel as parent. Setting font size should change the size of 
            fonts, title bar, and max/min/quit buttons. The settings are 3, 4, 7, 
            for 11 pixels. Currently the title bar size is hard-coded upon
            instantiation, but should be linked to changes in font size.
        '''

        self.master = master
        self.size = size
        self.menubar = menubar
        self.ribbon_menu = ribbon_menu

        sizes = {
            3: ['tiny', 20, 0.25],
            4: ['small', 25, 0.75],
            7: ['medium', 31, 0.25],
            11: ['large', 45, 1.0]
        }

        for k, v in sizes.items():
            if self.size == k:
                self.icon_size = v[0]
                self.offset_x = v[1]
                self.rel_y = v[2]

        self.changing_values = None
        self.maxxed = False

        self.formats = make_formats_dict()

        self.make_widgets()
Exemple #3
0
    def __init__(
            self, master, notebook, graphics_tab, root, 
            canvas,
            *args, **kwargs):
        Frame.__init__(self, master, *args, **kwargs)

        self.parent = master
        self.nbook = notebook
        self.t7 = graphics_tab
        self.root = root
        self.canvas = canvas
        self.counter = 0
        self.thumb_labels = []
        self.width_strings = []
        self.height_strings = []

        formats = make_formats_dict()

        self.current_person = get_current_person()[0]

        set_window_max_size(self.parent)
        self.filter_pix_data()
        self.make_widgets()        
Exemple #4
0
# toykinter_widgets.py

from styles import make_formats_dict
from widgets import Framex, FrameStay, Labelx, Frame, Label
from files import project_path
from PIL import Image, ImageTk

formats = make_formats_dict()

# ************** statusbar tooltips sizegrip **************


class LabelStatusbar(Labelx):
    def __init__(self, master, *args, **kwargs):
        Labelx.__init__(self, master, *args, **kwargs)
        self.config(bg=formats['bg'], fg=formats['fg'], font=formats['status'])


'''
    Statusbar messages on focus-in to individual widgets,
    non-obtrusive tooltips, and replacement for ttk.Sizegrip.
'''


def run_statusbar_tooltips(visited, status_label, tooltip_label):
    '''
        Uses lambda to add args to event
        since tkinter expects only one arg in a callback.
    '''
    def handle_statusbar_tooltips(event):
        for tup in visited:
Exemple #5
0
    def __init__(self,
                 master,
                 root,
                 callback=None,
                 height=480,
                 values=[],
                 scrollbar_size=24,
                 *args,
                 **kwargs):
        FrameHilited3.__init__(self, master, *args, **kwargs)
        '''
            This is a replacement for ttk.Combobox.
        '''

        self.master = master
        self.callback = callback
        self.root = root
        self.height = height
        self.values = values
        self.scrollbar_size = scrollbar_size

        self.formats = make_formats_dict()

        self.buttons = []
        self.selected = None
        self.result_string = ''

        self.entered = None
        self.lenval = len(self.values)
        self.owt = None
        self.scrollbar_clicked = False
        self.typed = None

        self.screen_height = self.winfo_screenheight()
        self.config(bd=0)

        # simulate <<ComboboxSelected>>:
        self.var = tk.StringVar()
        self.var.trace_add('write',
                           lambda *args, **kwargs: self.combobox_selected())

        # simulate ttk.Combobox.current()
        self.current = 0

        self.make_widgets()
        self.master.bind_all('<ButtonRelease-1>', self.close_dropdown, add='+')

        # self.root.bind('<Configure>', self.hide_all_drops) # DO NOT DELETE
        # Above binding closes dropdown if Windows title bar is clicked, it
        #   has no other purpose. But it causes minor glitches e.g. if a
        #   dropdown button is highlighted and focused, the Entry has to be
        #   clicked twice to put it back into the alternating drop/undrop
        #   cycle as expected. Without this binding, the click on the title
        #   bar lowers the dropdown below the root window which is good
        #   enough for now. To get around it, use the custom_window_border.py.

        # expose only unique methods of Entry e.g. not self.config (self is a Frame and
        #    the Entry, Toplevel, Canvas, and window have to be configured together) so
        #    to size the entry use instance.config_drop_width(72)
        self.insert = self.entry.insert
        self.delete = self.entry.delete
        self.get = self.entry.get
Exemple #6
0
# date_validation_new_model_part_2

# sample widgets which give input to a dates validation module and get input back from that module

import tkinter as tk
from tkinter import ttk
import sqlite3
import widgets as wdg
import date_validation_new_model_03 as dates
import styles as st

ST = st.ThemeStyles()
formats = st.make_formats_dict()


def use_input(input, widg):
    ''' for EntryLabel '''
    dates.get_widg_type(widg)


def get_event(evt):
    ''' for widgets other than EntryLabel '''
    widg = evt.widget
    dates.get_widg_type(widg)


date_in = ''

root = tk.Tk()
root.geometry('+10+600')