Exemplo n.º 1
0
 def on_key(event):
     c = event.char
     # print 'key pressed', repr(c), type(c)
     if c in 'adbcdefghijklmnopqrstuvwxyz0123456789':
         adb.input(c)
         return 'break'
     if c in keymap:
         adb.keyevent(keymap[c])
         return 'break'
Exemplo n.º 2
0
 def on_key(event):
     c = event.char
     # print 'key pressed', repr(c), type(c)
     if c in 'adbcdefghijklmnopqrstuvwxyz0123456789':
         adb.input(c)
         return 'break'
     if c in keymap:
         adb.keyevent(keymap[c])
         return 'break'
Exemplo n.º 3
0
        def make_toolbar(self):
            # tools: capture, power, home, menu, back, volume_up, volume_down, turn_screen, keymapping_settings
            toolbar = tk.Frame(self.root)
            self.icons = [] # need to keep a reference for tk images. wtf.

            def capture():
                if self.image is None:
                    print 'Not initialized, try later.'
                    return
                d = tkFileDialog.asksaveasfilename(filetypes=(('Images', '*.png;*.jpg;'),), initialfile='screen.png')
                if not d: # canceled
                    return
                if not d.endswith('.png') and not d.endswith('.jpg'):
                    d += '.png'
                print 'Save to', d
                self.image.save(d)
            icon = ImageTk.PhotoImage(file=os.path.join(__dir__, 'static', 'icons', 'save.ico'))
            tk.Button(toolbar, image=icon, command=capture).pack(side=tk.LEFT, padx=2, pady=2)
            self.icons.append(icon)

            # def rotate():
            #     print 'rotate screen (Not Implemented yet.)'
            # icon = ImageTk.PhotoImage(file=os.path.join(__dir__, 'static', 'icons', 'rotate.ico'))
            # tk.Button(toolbar, image=icon, command=rotate).pack(side=tk.LEFT, padx=2, pady=2)
            # self.icons.append(icon)

            for key in ('power', 'home', 'menu', 'back', 'volume_up', 'volume_down'):
                icon = ImageTk.PhotoImage(file=os.path.join(__dir__, 'static', 'icons', '%s.ico' % key))
                self.icons.append(icon)
                b = tk.Button(toolbar, image=icon, command=lambda k=key:adb.keyevent('KEYCODE_%s' % k.upper()))
                b.pack(side=tk.LEFT, padx=2, pady=2)

            toolbar.pack(side=tk.TOP, fill=tk.X)
Exemplo n.º 4
0
        def make_toolbar(self):
            # tools: capture, power, home, menu, back, volume_up, volume_down, turn_screen, keymapping_settings
            toolbar = tk.Frame(self.root)
            self.icons = []  # need to keep a reference for tk images. wtf.

            def capture():
                if self.image is None:
                    print 'Not initialized, try later.'
                    return
                d = tkFileDialog.asksaveasfilename(
                    filetypes=(('Images', '*.png;*.jpg;'), ),
                    initialfile='screen.png')
                if not d:  # canceled
                    return
                if not d.endswith('.png') and not d.endswith('.jpg'):
                    d += '.png'
                print 'Save to', d
                self.image.save(d)

            icon = ImageTk.PhotoImage(
                file=os.path.join(__dir__, 'static', 'icons', 'save.ico'))
            tk.Button(toolbar, image=icon, command=capture).pack(side=tk.LEFT,
                                                                 padx=2,
                                                                 pady=2)
            self.icons.append(icon)

            # def rotate():
            #     print 'rotate screen (Not Implemented yet.)'
            # icon = ImageTk.PhotoImage(file=os.path.join(__dir__, 'static', 'icons', 'rotate.ico'))
            # tk.Button(toolbar, image=icon, command=rotate).pack(side=tk.LEFT, padx=2, pady=2)
            # self.icons.append(icon)

            for key in ('power', 'home', 'menu', 'back', 'volume_up',
                        'volume_down'):
                icon = ImageTk.PhotoImage(
                    file=os.path.join(__dir__, 'static', 'icons', '%s.ico' %
                                      key))
                self.icons.append(icon)
                b = tk.Button(toolbar,
                              image=icon,
                              command=lambda k=key: adb.keyevent('KEYCODE_%s' %
                                                                 k.upper()))
                b.pack(side=tk.LEFT, padx=2, pady=2)

            toolbar.pack(side=tk.TOP, fill=tk.X)