TkCustomFrame.py 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
"""
  Nome: TkCustomFrame.py
  Autor: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )

  Descricão: TODO.
"""
import sys
if sys.version_info[0] < 3:
    import Tkinter as Tk
else:
    import tkinter as Tk
from TkUtils import Utils

17 18
from util.X11Colors import Colors

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
class CustomGrid(Tk.Frame):

    parent = None
    
    v = None
    
    def __init__(self, parent, width = 0, height = 0, bg='white'):
        self.parent = parent
        
        self.v = Tk.IntVar()
        
        Tk.Frame.__init__(self, self.parent, width=width, height=height, bg=bg)


    def add_cell_label(self, text, row, column, width=0, height=0, bg='white', fg="black"):
        
        Tk.Label(self, text=text, width=width, height=height, bg=bg, fg=fg, padx=4, pady=4).grid(row=row, column=column)
        
37 38 39
    def add_cell_button_color(self, text, row, column, width=0, height=0, bg='white', fg="black", command=None, command_args=None):
        
        bg_color = Colors.get_color_hex(bg)
40
        
41 42 43
        bt = Tk.Button(self, text=text, width=width, height=height, bg=bg_color, fg=fg, padx=0, pady=0, cursor="hand1",
                    command=lambda *_: command(command_args))
        bt.grid(row=row, column=column)
44
        
45
    def add_cell_radio_button(self, text, value, row, column, width=0, height=0, bg='white', fg="black", selected=False, command=None, command_args=None):
46 47 48
        
        radio = Tk.Radiobutton(self, text=text, variable=self.v, value=value, 
                                width=width, height=height, bg=bg, fg=fg, padx=4, pady=4, 
49
                                indicatoron=1, anchor=Tk.W, command=lambda *_: command(command_args),
50 51 52 53 54 55 56
                                activebackground='#404040', highlightbackground='white')
        
        radio.grid(row=row, column=column)

        if(selected == True):
            radio.select()