Example #1
0
    def __init__(self, title, label_ok="OK", label_cancel="Cancel"):

        self.__inputs = []
        self.__return_code = self.RETURN_CANCEL

        # list of value retrieving functions
        self.__retrievers = []

        Window.__init__(self, Window.TYPE_DIALOG)
        self.set_flag(windowflags.EXCLUSIVE, True)
        self.connect_closed(self.__on_close, self.RETURN_CANCEL)
        self.set_title(title)

        self.__box = Widget()
        self.add(self.__box)

        self.__button_ok = Button(label_ok)
        self.__button_ok.connect_clicked(self.__on_close, self.RETURN_OK)
        self.__box.add(self.__button_ok)

        if (not platforms.MAEMO5):
            self.__button_cancel = Button(label_cancel)
            self.__button_cancel.connect_clicked(self.__on_close,
                                                 self.RETURN_CANCEL)
            self.__box.add(self.__button_cancel)

        self.__vbox = VBox()
        self.__box.add(self.__vbox)
Example #2
0
    def __init__(self):

        self.__title = ""
        self.__info = ""

        Component.__init__(self)
        Window.__init__(self, Window.TYPE_SUBWINDOW)
        self.connect_closed(self.__on_close_window)
Example #3
0
 def __init__(self, camera, size=(640, 480)):
     """ Default constructor. """
     self.inCapture = False
     self.camera = camera
     self.window = Window(size=size)
     self.currentMode = PHOTO_MODE
     self.root = Panel(orientation='horizontal', )
     self.sidebar = Panel(orientation='vertical', padding=10)
     self.mode = Panel(orientation='horizontal', padding=10)
     self.modeLabel = Label('Photo', size='large')
     self.bind()
Example #4
0
    def __init__(self, title):

        self.__choice = None

        Window.__init__(self, Window.TYPE_DIALOG)
        self.set_flag(windowflags.EXCLUSIVE, True)
        self.connect_closed(self.__on_close)
        self.set_title(title)

        self.__list = ThumbableGridView()
        self.add(self.__list)
Example #5
0
    def run(self):

        w = gtk.gdk.screen_width()
        h = min(gtk.gdk.screen_height() - 120, len(self.__retrievers) * 120)

        if (not platforms.MAEMO5):
            w -= 80
            h += 70
        self.set_window_size(w, h)
        Window.run(self)

        return self.__return_code
Example #6
0
class Loader(object):
    """ Loader class. """

    def __init__(self, size=(640, 480)):
        """ Default constructor. """
        self.size = size
        self.window = Window(size=size, fullscreen=False, backgroundColor=WHITE)
        self.container = Panel(orientation='vertical')
        self.window.add(self.container)
    
    def welcome(self):
        """ Welcome screen. """
        header = Label('Bienvenue', color=BLACK, size='huge')
        message = Label('Appuyer pour commencer', color=BLACK, size='medium')
        self.container.add(header)
        self.container.add(message)
        def onClick(position):
            """ Window click callback. """
            self.container.remove(header)
            self.container.remove(message)
            self.window.onWindowClick = None
            self.prompt('Voulez vous configurer la connection internet ?', lambda r: self.wifi(r))
        self.window.onWindowClick = onClick

    def prompt(self, question, callback):
        """ Prompt screen (Yes / No question only) """
        header = Label(question, color=BLACK, size='medium')
        panel = Panel(orientation='horizontal', padding=20)
        def createPromptCallback(callback, answer):
            def delegate():
                self.container.remove(header)
                self.container.remove(panel)
                callback(answer)
            return delegate
        yes = Label(' Oui ', color=WHITE, background=GRAY, size='medium')
        no = Label(' Non ', color=WHITE, background=GRAY, size='medium')
        yes.onClick = createPromptCallback(callback, True)
        no.onClick = createPromptCallback(callback, False)
        panel.add(yes)
        panel.add(no)
        self.container.add(header)
        self.container.add(panel)
        self.window.invalidate()

    def wifi(self, configure):
        """ WiFi configuration screen. """
        if configure:
            # TODO : Set RPI as WiFi hotspot.
            # TODO : Start webserver.
            # TODO : Quit and go next.
            pass
        else:
            quit()
Example #7
0
    def ListWithScrollbar(cls, master):
        '''Sample usage:
            from com.ui import ROOT    
            frame1 = Widget.Labelframe(ROOT,text = "sssss")
            frame1.rowconfigure(0,weight =1, minsize = 0)
            frame1.columnconfigure(0,weight =1, minsize = 0)
            Window.widg = frame1
            Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c")
                
            (l,x,y) = Components.ListWithScrollbar(frame1)
            elems = ["Don't speculate, measure", "Waste not, want not", "Early to bed and early to rise makes a man healthy, wealthy, and wise", "Ask not what your country can do for you, ask what you can do for your country", "I shall return", "NOT", "A picture is worth a thousand words", "User interfaces are hard to build", "Thou shalt not steal", "A penny for your thoughts", "Fool me once, shame on you;  fool me twice, shame on me", "Every cloud has a silver lining", "Where there's smoke there's fire", "It takes one to know one", "Curiosity killed the cat", "Take this job and shove it", "Up a creek without a paddle", "I'm mad as hell and I'm not going to take it any more", "An apple a day keeps the doctor away", "Don't look a gift horse in the mouth", "Measure twice, cut once"]
            l.insert(0,*elems)
            ROOT.mainloop()
        '''
        f = TkFont()
        lb = Widget.Listbox(master,
                            width=60,
                            height=24,
                            font=f.font,
                            setgrid=1)
        s_x = Widget.Scrollbar(master,
                               orient=Tkconstants.HORIZONTAL,
                               command=lb.xview)
        s_y = Widget.Scrollbar(master,
                               orient=Tkconstants.VERTICAL,
                               command=lb.yview)

        Window.widg = s_y
        Window.Pack(side="right", fill="y")

        Window.widg = s_x
        Window.Pack(side="bottom", fill="x")

        Window.widg = lb
        Window.Config(xscrollcommand=s_x.set, yscrollcommand=s_y.set)
        Window.Pack(side="top", fill="both", expand="yes")

        #         lb = Widget.Listbox(master, width = 20, height = 10, setgrid = 1)
        #         s_x = Widget.Scrollbar(master,orient = Tkconstants.HORIZONTAL, command = lb.xview)
        #         s_y = Widget.Scrollbar(master,orient = Tkconstants.VERTICAL, command = lb.yview)
        #
        #         Window.widg = lb
        #         Window.Config(xscrollcommand = s_x.set, yscrollcommand = s_y.set)
        #         Window.Grid(row =0, column = 0, rowspan = 1, columnspan = 1, sticky = Tkconstants.NSEW)
        #
        #         Window.widg = s_y
        #         Window.Grid(row =0, column = 1, rowspan = 1, columnspan = 1, sticky = Tkconstants.NSEW)
        #
        #         Window.widg = s_x
        #         Window.Grid(row =1, column = 0, rowspan = 1, columnspan = 1, sticky = Tkconstants.NSEW)

        return (lb, s_x, s_y)
Example #8
0
    def run(self):

        w = gtk.gdk.screen_width()
        h = min(gtk.gdk.screen_height() - 120, self.__num_of_options * 80)
        if (platforms.MAEMO4):
            w -= 80
        self.set_window_size(w, h)

        Window.run(self)

        if (self.__choice == -1):
            return self.RETURN_CANCEL
        else:
            return self.RETURN_OK
Example #9
0
    def PaneWithLabelframe(cls,
                           master,
                           f_name,
                           s_name,
                           orient=Tkconstants.HORIZONTAL):
        '''Sample usage:
            from com.ui import ROOT    
            (frame1, frame2) = Components.PaneWithLabelframe(ROOT, "frame1", "frame2")[1:]
            Window.widg = Widget.Button(frame1,text = "button1")
            Window.Pack()
            
            Window.widg = Widget.Button(frame2,text = "button2")
            Window.Pack()
            ROOT.mainloop()
        '''
        p = Widget.Panedwindow(master, orient=orient)
        l1 = Widget.Labelframe(master, text=f_name)
        l2 = Widget.Labelframe(master, text=s_name)
        p.add(l1)
        p.add(l2)
        Window.widg = p
        Window.Pack(side="top",
                    fill=Tkconstants.BOTH,
                    expand=Tkconstants.YES,
                    pady=2,
                    padx=2)

        return (p, l1, l2)
Example #10
0
    def render_this(self):

        Window.render_this(self)

        x, y = self.__box.get_screen_pos()
        w, h = self.__box.get_size()
        screen = self.__box.get_screen()

        screen.fill_area(x, y, w, h, theme.color_mb_background)

        if (not platforms.MAEMO5):
            self.__vbox.set_geometry(4, 4, w - 8, h - 78)
            self.__button_ok.set_geometry(w - 260, h - 60, 120, 60)
            self.__button_cancel.set_geometry(w - 130, h - 60, 120, 60)

        else:
            self.__vbox.set_geometry(6, 5, w - 165 - 12, h - 5)
            self.__button_ok.set_geometry(w - 120, h - 80, 100, 60)
Example #11
0
    def LabelWithEntryAndButton(cls, master, grid_tree):
        '''Sample usage
            from com.ui import ROOT    
            frame1 = Widget.Labelframe(ROOT,text = "YYYY")
            Window.widg = frame1        
            Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c")
            
            grid_tree = [
                        [(u"用户名:", u"登录")],
                        [(u"密码:", ""),(u"验证码:", "")], 
                    ]
            widgets = Components.LabelWithEntryAndButton(frame1, grid_tree)
            widgets[0][1].insert("end","hi handsome boy.")    
            ROOT.mainloop()
        '''
        result = []
        rows = len(grid_tree)
        for row in range(rows):
            result.append([])
            column = -1

            groups = grid_tree[row]
            for lable_name, button_name in groups:
                column = column + 1
                label = Widget.Label(master, text=lable_name)
                result[row].append(label)
                Window.widg = label
                Window.Grid(row, column, "w")

                column = column + 1
                entry = Widget.Entry(master)
                result[row].append(entry)
                Window.widg = entry
                Window.Grid(row, column, "ew")

                if button_name:
                    column = column + 1
                    button = Widget.Button(master, text=button_name)
                    result[row].append(button)
                    Window.widg = button
                    Window.Grid(row, column, "e")
        return result
Example #12
0
    def TextWithScrollbar(cls, master):
        '''Sample usage:
            from com.ui import ROOT    
            frame1 = Widget.Labelframe(ROOT,text = "XXXX")
            Window.widg = frame1        
            Window.Pack(side = "top", fill="both", expand="yes", padx = "0.2c")
            
            (t,x,y) = Components.TextWithScrollbar(frame1)    
            t.insert("end","0.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\n")
            t.insert("end","1.sdf\n")    
            ROOT.mainloop()
        '''
        f = TkFont()
        # wrap -->设置当一行文本的长度超过width选项设置的宽度时,是否换行; "none"不自动换行, "char"按字符自动换行, "word"按单词自动换行
        # undo -->设置文本 是否可以 撤销 和 恢复; 默认值是  0 或者 False,表示没有开启
        tx = Widget.Text(master,
                         width=60,
                         height=24,
                         font=f.font,
                         wrap="word",
                         setgrid=1,
                         undo=True,
                         background="white")
        s_x = Widget.Scrollbar(master,
                               orient=Tkconstants.HORIZONTAL,
                               command=tx.xview)
        s_y = Widget.Scrollbar(master,
                               orient=Tkconstants.VERTICAL,
                               command=tx.yview)

        Window.widg = s_y
        Window.Pack(side="right", fill="y")

        Window.widg = s_x
        Window.Pack(side="bottom", fill="x")

        Window.widg = tx
        Window.Config(xscrollcommand=s_x.set, yscrollcommand=s_y.set)
        Window.Pack(side="top", fill="both", expand="yes")

        return (tx, s_x, s_y)
Example #13
0
def run():
    parser = ArgumentParser(description='Scrabble game including an AI.')
    parser.add_argument('players',
                        metavar='PLAYER',
                        type=str,
                        nargs='+',
                        help='A player like "TYPE:NAME", valid types are:' +
                        ' bot, human')
    parser.add_argument('-r',
                        '--rows',
                        type=int,
                        default=11,
                        dest='rows',
                        help='Board rows (default: 11)')
    parser.add_argument('-c',
                        '--columns',
                        type=int,
                        default=11,
                        dest='columns',
                        help='Board columns (default: 11)')
    parser.add_argument('-s',
                        '--rack',
                        type=int,
                        default=7,
                        dest='rack',
                        help='Rack size (default: 7)')
    parser.add_argument('-w',
                        '--words',
                        type=str,
                        default=DEFAULT_WORDLIST,
                        dest='words',
                        help='Bot words file (default: %s)' % DEFAULT_WORDLIST)
    parser.add_argument('-l',
                        '--letters',
                        type=str,
                        default=DEFAULT_LETTERSET,
                        dest='letters',
                        help='Letter-set file (default: %s)' %
                        DEFAULT_LETTERSET)

    args = parser.parse_args()

    game = Game(args.rows, args.columns, args.rack, args.letters)

    for player in args.players:
        typ, name = player.split(':')
        game.add_player(
            BruteForceBot(name, game, words=args.words) if typ.lower() ==
            'bot' else Human(name, game))

    app = QApplication(argv)
    win = Window(game)
    app.exec_()
Example #14
0
    def render_this(self):

        w, h = self.get_size()

        if ((w, h) != self.__window_size):
            self.__update_items_per_row(self.__browser.get_current_folder())
            self.__window_size = (w, h)

        if (self.__arr.is_visible()):
            Window.render_this(self)

        elif (self.__is_shutdown):
            x, y = self.get_screen_pos()
            screen = self.get_screen()

            screen.fill_area(x, y, w, h, theme.color_mb_background)
            screen.draw_centered_text(values.NAME + " " + values.VERSION,
                                      theme.font_mb_headline, x, h / 2 - 30, w,
                                      30, theme.color_mb_text)
            screen.draw_centered_text(values.COPYRIGHT, theme.font_mb_plain, x,
                                      h / 2, w, 30, theme.color_mb_text)
            screen.draw_centered_text("Exiting...", theme.font_mb_plain, x,
                                      h - 80, w, 20, theme.color_mb_text)
            screen.fit_pixbuf(theme.mb_logo, w - 120, h - 120, 120, 120)

        else:
            x, y = self.get_screen_pos()
            screen = self.get_screen()

            screen.fill_area(x, y, w, h, theme.color_mb_background)
            screen.draw_centered_text(values.NAME + " " + values.VERSION,
                                      theme.font_mb_headline, x, h / 2 - 30, w,
                                      30, theme.color_mb_text)
            screen.draw_centered_text(values.COPYRIGHT, theme.font_mb_plain, x,
                                      h / 2, w, 30, theme.color_mb_text)
            screen.draw_centered_text("Loading... Please Wait",
                                      theme.font_mb_plain, x, h - 80, w, 20,
                                      theme.color_mb_text)
            screen.fit_pixbuf(theme.mb_logo, w - 120, h - 120, 120, 120)
Example #15
0
    def RadioWithLabelframe(cls, master, texts=[], values=[], command=None):
        '''Sample usage:
            from ui import ROOT    
            frame1 = Widget.Labelframe(ROOT,text = "XXXX")
            Window.widg = frame1        
            Window.Pack(side = "left", fill="both", expand="no", padx = "0.2c")
                    
            frame2 = None
            def test(a):
                print a
                if frame2:
                    frame2.config(text = var.get())
                    t.delete("1.0","end")
                    t.insert("end",var.get())
                
            var,rds = Components.RadioWithLabelframe(frame1, texts = [1,2,3,4,5], values = [1,2,3,4,5], command = lambda: test("if command has parameter; please use lambda.like this"))
            
            frame2 = Widget.Labelframe(ROOT,text = "YYYY")        
            Window.widg = frame2
            Window.Pack(side = "left", fill="both", expand="yes", padx = "0.2c")
            (t,x,y) = Components.TextWithScrollbar(frame2)
                    
            ROOT.mainloop()
        '''
        radios = []
        var = Tkinter.StringVar()
        radio_items = dict(zip(texts, values))
        for text, value in radio_items.items():
            Window.widg = Widget.Radiobutton(master, variable=var)
            Window.Config(text=text, value=value)
            if command:
                Window.Config(command=command)
            Window.Pack(side="top", fill="x", expand="yes", pady=2, anchor="w")
            radios.append(Window.widg)

        if radios:
            return var, radios
Example #16
0
def draw_promotion_prompt(screen, screen_width, screen_height, bwidth):
    board_center = position_to_board((3, 4), bwidth)
    screen_center = board_to_screen(board_center, screen_width, screen_height,
                                    bwidth)
    # Prompt window
    window = Window(250, 100)
    window.set_position(screen_center)
    # Yes and No buttons
    yes_button = Button('yes', 100, 50, GREEN)
    yes_button.set_position(
        (screen_center[0] + 10, screen_center[1] + 2 * window.height / 4))
    no_button = Button('no', 100, 50, RED)
    no_button.set_position(
        (2 * screen_center[0] - 140, screen_center[1] + 2 * window.height / 4))
    window.add_buttons([yes_button, no_button])
    # Draw window and buttons
    window.draw(screen)

    # Draw prompt at the center
    font = pygame.font.SysFont(None, 25)
    text_surf = font.render("Do you wish to promote?", True, BLACK)
    text_rect = text_surf.get_rect()
    board_center = position_to_board((5, 4), bwidth)
    screen_center = board_to_screen(board_center, screen_width, screen_height,
                                    bwidth)
    text_rect.center = (screen_center[0] + 25, screen_center[1] + 25)
    screen.blit(text_surf, text_rect)

    yes_surf = font.render("Yes", True, BLACK)
    yes_rect = yes_surf.get_rect()
    board_center = position_to_board((4, 5), bwidth)
    screen_center = board_to_screen(board_center, screen_width, screen_height,
                                    bwidth)
    yes_rect.center = (screen_center[0] + 10, screen_center[1] + 25)
    screen.blit(yes_surf, yes_rect)

    no_surf = font.render("No", True, BLACK)
    no_rect = no_surf.get_rect()
    board_center = position_to_board((6, 5), bwidth)
    screen_center = board_to_screen(board_center, screen_width, screen_height,
                                    bwidth)
    no_rect.center = (screen_center[0] + 40, screen_center[1] + 25)
    screen.blit(no_surf, no_rect)

    return window
    """
Example #17
0
class Communication:
    HEADER_LENGTH = 10
    w = Window()

    def clientCreate(self):
        client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        return client_socket

    def clientConnect(self, client_socket):
        client_socket.connect((self.w.ip.text, int(self.w.port.text)))
        client_socket.setblocking(False)
        print(f'Connecting to: {self.ip.text}  on port: {self.port.text}')

    def clientSend(self, client_socket, data):
        data = data.encode('utf-8')
        data_header = f'{len(data):<{self.HEADER_LENGTH}}'.encode('utf-8')
        client_socket.send(data_header + data)

    '''
Example #18
0
 def __init__(self, size=(640, 480)):
     """ Default constructor. """
     self.size = size
     self.window = Window(size=size, fullscreen=False, backgroundColor=WHITE)
     self.container = Panel(orientation='vertical')
     self.window.add(self.container)
Example #19
0
        '''
        radios = []
        var = Tkinter.StringVar()
        radio_items = dict(zip(texts, values))
        for text, value in radio_items.items():
            Window.widg = Widget.Radiobutton(master, variable=var)
            Window.Config(text=text, value=value)
            if command:
                Window.Config(command=command)
            Window.Pack(side="top", fill="x", expand="yes", pady=2, anchor="w")
            radios.append(Window.widg)

        if radios:
            return var, radios


if __name__ == "__main__":
    from ui import ROOT
    frame1 = Widget.Labelframe(ROOT, text="XXXX")
    Window.widg = frame1
    Window.Pack(side="top", fill="both", expand="yes", padx="0.2c")

    (t, x, y) = Components.TextWithScrollbar(frame1)
    t.insert(
        "end",
        "0.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\n"
    )
    t.insert("end", "1.sdf\n")
    t.insert("end", 1)
    ROOT.mainloop()
Example #20
0
from ui import Window

window = Window()

window.Run()
Example #21
0
from ui import Window

from PyQt5.QtWidgets import QApplication
import sys

App = QApplication(sys.argv)

window = Window()

sys.exit(App.exec())
Example #22
0
    def TreeviewWithScrollbar(cls, master, head_names):
        '''Sample usage:
            from com.ui import ROOT    
            heads = [u"第一列", u"第二列"]
            datas = [("Argentina","Buenos Aires"),("Australia","Canberra"),("Brazil","Brazilia"),("Canada","Ottawa"),("China","Beijing"),("France","Paris")]    
            tree = Components.TreeviewWithScrollbar(ROOT,heads)[0]
            # Add
            items_list = []
            for data in datas:
                items_list.append(tree.insert("", "end", values = data))
            print "all items: ", items_list
                    
            # Select
            print tree.column('col0')
            
            tree.selection_set("I001")
            print "current selection: ", tree.selection()
            print "current index: ", tree.index("I001")
            
            tree.tag_configure("t_tag", font = u"宋体   12 normal italic", foreground="red")
            tree.item('I001',tags = "t_tag")
            
            item_info = tree.item('I001')
            print "item info: ", item_info
            
            # Update
            c_value = ("Oh", "Handsome boy.")
            tree.item('I001',values = c_value)
            print "%s changing to %s" %(datas[tree.index("I001")], c_value)       
            
            print "item value dict: %s" %tree.set("I002")
            print "column value: %s" %tree.set("I002","col0")
            print "set column value to 'HaLo'"
            tree.set("I002","col0","Halo")
            
            # Delete
            tree.delete("I006")
            print "deleted France item."
            
            ROOT.mainloop()   
        '''

        columns = []
        for i in range(len(head_names)):
            columns.append("col%d" % i)
        columns_and_headnames = zip(columns, head_names)

        t = Widget.Treeview(master, columns=columns, show="headings")
        for (col, text) in columns_and_headnames:
            t.column(col, width=100, anchor="center")
            t.heading(col, text=text)

        s_x = Widget.Scrollbar(master,
                               orient=Tkconstants.HORIZONTAL,
                               command=t.xview)
        s_y = Widget.Scrollbar(master,
                               orient=Tkconstants.VERTICAL,
                               command=t.yview)

        Window.widg = s_y
        Window.Pack(side="right", fill="y")

        Window.widg = s_x
        Window.Pack(side="bottom", fill="x")

        Window.widg = t
        Window.Config(xscrollcommand=s_x.set, yscrollcommand=s_y.set)
        Window.Pack(side="top", fill="both", expand="yes", pady=2, padx=2)

        return (t, s_x, s_y)
Example #23
0
# GREETINGS = ["こんにちは", "はい"]

from bot import Bot
from ui import Window
import tkinter as tk


def send_message(msg_in):
    return the_bot.respond(msg_in)


def exit_program():
    raise SystemExit()


root = tk.Tk()
tk.Grid.rowconfigure(root, 0, weight=1)
tk.Grid.columnconfigure(root, 0, weight=1)
app = Window(root, send_message, exit_program)
the_bot = Bot(app.add_reply, app.ask, app.update_dict)

root.mainloop()
Example #24
0
    def __init__(self):

        # the current mode
        self.__mode = _MODE_NORMAL

        # list of available dialog windows
        self.__dialogs = []

        self.__widgets = []

        # the file that is currently playing
        self.__current_file = None

        # list of files for playing
        self.__play_folder = None
        self.__play_files = []

        # list for choosing random files from when in shuffle mode
        self.__random_files = []

        # current window size (for detecting resizing)
        self.__window_size = (0, 0)

        self.__is_searching = False
        self.__filter_term = ""

        self.__key_hold_down_timestamp = 0
        self.__skip_letter = False

        # scheduler for creating thumbnails one by one
        self.__tn_scheduler = ItemScheduler()

        # whether we are shutting down
        self.__is_shutdown = False

        Component.__init__(self)
        Window.__init__(self, Window.TYPE_TOPLEVEL)
        self.set_flag(windowflags.CATCH_VOLUME_KEYS, True)
        self.connect_key_pressed(self.__on_key_press)
        self.connect_closed(self.__on_close_window)

        # [Now Playing] button
        self.__now_playing = NowPlaying()
        #self.__now_playing.set_visible(False)

        # file browser
        self.__browser = StorageBrowser()
        #self.__browser.set_root_device(self.__root_dev)
        self.__browser.connect_folder_begin(self.__on_begin_folder)
        self.__browser.connect_folder_progress(self.__on_progress_folder)
        self.__browser.connect_folder_complete(self.__on_complete_folder)
        self.__browser.connect_file_opened(self.__on_open_file)
        self.__browser.connect_item_shifted(self.__on_shift_item)

        # toolbar
        self.__toolbar = Toolbar()

        self.__btn_home = ToolbarButton(theme.mb_btn_home_1)
        self.__btn_home.connect_clicked(self.__on_btn_home)

        self.__btn_history = ToolbarButton(theme.mb_btn_history_1)
        self.__btn_history.connect_clicked(self.__on_btn_history)

        self.__btn_bookmarks = ToolbarButton(theme.mb_btn_bookmark_1)
        self.__btn_bookmarks.connect_clicked(self.__on_btn_bookmarks)

        self.__btn_back = ToolbarButton(theme.mb_btn_dir_up_1)
        self.__btn_back.connect_clicked(self.__on_btn_back)

        self.__btn_select_all = ToolbarButton(theme.mb_btn_select_all_1)
        self.__btn_select_all.connect_clicked(self.__on_btn_select_all)

        self.__btn_select_none = ToolbarButton(theme.mb_btn_select_none_1)
        self.__btn_select_none.connect_clicked(self.__on_btn_select_none)

        self.__btn_select_done = ToolbarButton(theme.mb_btn_select_done_1)
        self.__btn_select_done.connect_clicked(self.__on_btn_select_done)

        # arrangement
        self.__arr = Arrangement()
        self.__arr.connect_resized(self.__update_layout)
        self.__arr.add(self.__now_playing, "now-playing")
        self.__arr.add(self.__browser, "browser")
        self.__arr.add(self.__toolbar, "toolbar")
        self.add(self.__arr)
        self.__arr.set_visible(False)

        # we have to fill the menu with content before showing the window on
        # Maemo5 or the window will show no menu at all
        self.__update_menu()

        self.set_visible(True)
Example #25
0
class PiBooth(object):
    """ Main application. """
    def __init__(self, camera, size=(640, 480)):
        """ Default constructor. """
        self.inCapture = False
        self.camera = camera
        self.window = Window(size=size)
        self.currentMode = PHOTO_MODE
        self.root = Panel(orientation='horizontal', )
        self.sidebar = Panel(orientation='vertical', padding=10)
        self.mode = Panel(orientation='horizontal', padding=10)
        self.modeLabel = Label('Photo', size='large')
        self.bind()

    def bind(self):
        """ """
        self.sidebar.add(self.mode)
        self.root.add(self.sidebar)
        self.window.add(self.root)

    def createModeController(self):
        """ Creates and configures widget for booth mode controller. """
        photo = Image('resources/icons/photo.png')
        video = Image('resources/icons/video.png')
        self.mode.add(photo)
        self.mode.add(self.modeLabel)
        self.mode.add(video)
        photo.onClick = lambda: self.setMode(PHOTO_MODE)
        video.onClick = lambda: self.setMode(VIDEO_MODE)

    def createRecordButton(self):
        """ """
        # TODO : Use centered button.
        container = Panel(orientation='horizontal', padding=30)
        button = Image('resources/icons/record.png')
        button.onClick = lambda: self.capture()
        container.add(button)
        self.sidebar.add(container)

    def createSettings(self):
        """ Creates and configures widget for photo configuration. """
        self.effects = self.camera.effects()
        self.currentEffect = 0
        effectPanel = Panel(orientation='horizontal', padding=0)
        effectPanel.add(Image('resources/icons/filter.png'))
        container = Panel(orientation='horizontal', padding=10)
        prevEffect = Label('<', size='large')
        nextEffect = Label('>', size='large')
        self.effectLabel = Label(self.effects[self.currentEffect],
                                 size='large')
        container.add(prevEffect)
        container.add(self.effectLabel)
        container.add(nextEffect)
        effectPanel.add(container)
        self.sidebar.add(effectPanel)

    def capture(self):
        """ """
        pass

    def setMode(self, mode):
        """ Sets current mode and updates UI accordingly. """
        if self.inCapture or mode == self.currentMode: return
        self.modeLabel.text = 'Photo' if mode == PHOTO_MODE else 'Video'
        self.currentMode = mode
        self.window.invalidate()

    def setEffect(self, iteration):
        """ Sets the current camera filter and updates UI accordingly. """
        self.currentEffect += iteration
        if self.currentEffect < 0:
            self.currentEffect = len(self.effects) - 1
        elif self.currentEffect >= len(self.effects):
            self.currentEffect = 0
        self.camera.setEffect(self.effects[self.currentEffect])
        self.effectLabel.text = self.effects[self.currentEffect]
        self.window.invalidate()
Example #26
0
def main(root):
    window = Window(root, db)
    window.login_page_init()
    root.eval("tk::PlaceWindow . center")

    root.mainloop()
Example #27
0
def main(root):
    window = Window(root, db)
    window.login_page_init()
    root.mainloop()
Example #28
0
 def __init__(self):
     Window.InitUI(self)