Exemplo n.º 1
0
    def __init__(self):
        """
            Initialises all the components in the user interface.
        """
        self.root = tk.Tk()
        self.colour_box = tk.Label(self.root)

        self.hex_frame = tk.LabelFrame(self.root, text="Hex")
        self.hex_label = tk.Label(self.hex_frame, text="Hex: #")
        self.hex_input = tk.Entry(self.hex_frame)
        self.hex_input.bind("<KeyRelease>", self.update_hex)

        self.rgb_frame = tk.LabelFrame(self.root, text="RGB")
        self.red_label = tk.Label(self.rgb_frame, text="Red:")
        self.red_input = tk.Entry(self.rgb_frame)
        self.red_input.bind("<KeyRelease>", self.update_rgb)
        self.green_label = tk.Label(self.rgb_frame, text="Green:")
        self.green_input = tk.Entry(self.rgb_frame)
        self.green_input.bind("<KeyRelease>", self.update_rgb)
        self.blue_label = tk.Label(self.rgb_frame, text="Blue:")
        self.blue_input = tk.Entry(self.rgb_frame)
        self.blue_input.bind("<KeyRelease>", self.update_rgb)

        self.clipboard_image = ImageTk.PhotoImage(
            Image.open("./clipboard.png").resize((30, 30)), Image.ANTIALIAS)
        self.input_boxes = {
            "red": self.red_input,
            "green": self.green_input,
            "blue": self.blue_input,
            "hex": self.hex_input
        }

        self.hex_clipboard_button = tk.Button(
            self.hex_frame,
            image=self.clipboard_image,
            command=lambda: Clipboard().copy_to_clipboard(
                self.root, self.input_boxes, "hex"))
        self.rgb_clipboard_button = tk.Button(
            self.rgb_frame,
            image=self.clipboard_image,
            command=lambda: Clipboard().copy_to_clipboard(
                self.root, self.input_boxes, "rgb"))

        self.colours = {
            "invalid input": "#FF726F",
            "default background": "#1D1D1D",
            "secondary": "#FFFFFF",
            "colour box": "#FF0000"
        }

        self.default_font_size = 14
Exemplo n.º 2
0
    def _save_record(self):
        """
        Save the details of an uploaded file to the history file and send the link to its destination

        link - The link to the uploaded file
        paths - An array of paths to all the files and folders that were uploaded
        share_to - A string describing the intended destination of the link -
                   either the clipboard, a social network or stdout
        """

        if not self.link:
            return

        # save a record of it to the history,
        for path, filename in zip(self.paths, self.filenames):
            History().add(path, filename, self.link)

        # and then send the link to its destination, be that clipboard or social network.
        if self.share_to == 'clipboard':
            Clipboard().set(self.link)
        elif self.share_to == 'stdout':
            import sys
            sys.stdout.write(self.link)
        else:
            url = URLS[self.share_to] % (SHARE_MESSAGE, self.link)
            webbrowser.open(url, new=2)
Exemplo n.º 3
0
 def __init__(self, config, args):
     self.config = config
     self.ndb = args['ndb']
     self.key = args['key']
     self.log = args['log']
     self.search_string = ''
     self.search_mode = 'gstyle'
     self.search_direction = ''
     self.note = self.ndb.get_note(self.key) if self.key else None
     self.old_note = None
     self.tabstop = int(self.config.get_config('tabstop'))
     self.clipboard = Clipboard()
     super(ViewNote, self).__init__(
         urwid.SimpleFocusListWalker(self.get_note_content_as_list()))
Exemplo n.º 4
0
def snippet(args):
    """Upload the contents of the user's clipboard as a text file"""

    # Get the contents of the clipboard
    clipboard = Clipboard().get()
    if clipboard is None:
        return

    if args.text == 'dropbox':
        # Create a unique name for the text file the snippet will be stored in
        # With the extension specified by the user
        filename = 'text_snippet_%d.%s' % (time(), args.extension)
        path = os.path.join(TMP_PATH, filename)

        # Save it
        f = open(path, 'w')
        f.write(clipboard)
        f.close()

        # Upload it
        c.handle_files([path], [filename], args.share)
Exemplo n.º 5
0
    def __init__(self):
        # Qt application
        self._app = QtWidgets.QApplication([sys.argv[0]])

        # Translation engine (will be set by events)
        self._gtrans = GTransWeb()

        # Clipboard and its handler
        self._clipboard = Clipboard(self._app)
        self._clip_handler = ClipboardHandler(self._clipboard)
        self._clip_handler.set_callback(self._on_clip_changed)
        # Main window
        self._window = Window(self._translate, self._on_clipmode_changed,
                              self._on_backendmode_changed,
                              self._on_headless_changed,
                              self._clipboard.get_mode_strs(),
                              GTransWeb.BACKEND_MODES)
        # Buffer for selection mode
        self._select_buf = CallableBuffer()

        # Exit function should be call at exit
        atexit.register(self.exit)
Exemplo n.º 6
0
 def __removeItemsFromClipboard(self):
     cb = Clipboard()
     cb.put(*self.__previousClipboardContents)
Exemplo n.º 7
0
 def __putItemsOnClipboard(self):
     cb = Clipboard()
     self.__previousClipboardContents = cb.get()  # pylint: disable=W0201
     cb.put(self.itemsToCut(), self.sourceOfItemsToCut())
Exemplo n.º 8
0
 def redo_command(self):
     Clipboard().put(self.__copies, self.list)
Exemplo n.º 9
0
 def undo_command(self):
     Clipboard().clear()
Exemplo n.º 10
0
 def do_command(self):
     self.__copies = [item.copy() for item in self.items]  # pylint: disable=W0201
     Clipboard().put(self.__copies, self.list)
Exemplo n.º 11
0
 def getItemsToPaste(self):
     return Clipboard().get()
Exemplo n.º 12
0
    def __init__(self, prevroot, datawve):
        """
        Create a waveinterface instance.

        :param prevroot: is the main window 
        :param datawve: is the datapoints to play with
        :returns: a new instance of wave interface

        """
        self.root = maketoplevel(prevroot, True)
        self.root.title("Wave editor")

        self.datawve = datawve

        self.dataclpbrd = []
        self.clipboardtime = 0

        row = 0
        col = 0
        self.tablewve = Table(self.root, self.datawve,
                              ('step', 'time [s]', ('voltage [V]', VCOL),
                               ('current [A]', CCOL)), row, col, TABLEROW,
                              TABLECOL)

        SCOPEROWSPAN = 15
        self.scope = Scope(self.root,
                           self.datawve,
                           TABLEROW + 1 + 1,
                           0,
                           rowspan=SCOPEROWSPAN,
                           showpower=False,
                           horizontaljoin=True,
                           buttoncallback=self.buttoncallback)

        row = 1
        rowspan = 1
        colspan = 1
        col = TABLECOL + colspan
        Button(self.root, text="Pick beg",
               command=self.btncmdpckbeg).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)
        col = TABLECOL + colspan
        row += rowspan
        Button(self.root, text="Pick end",
               command=self.btncmdpckend).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)

        Separator(self.root,
                  orient='horizontal').grid(row=TABLEROW + 1,
                                            column=0,
                                            columnspan=TABLECOL + 2 + 1 + 6,
                                            sticky=E + W,
                                            pady=8)

        Separator(self.root, orient='vertical').grid(row=0,
                                                     column=6,
                                                     rowspan=1 + TABLEROW + 1 +
                                                     SCOPEROWSPAN,
                                                     sticky=N + S,
                                                     padx=8)

        row = 0
        COL1 = TABLECOL + 2 + 1
        col = COL1
        colspan = 1
        insertlabelrow(self.root, row, col, (None, None, ('voltage [V]', VCOL),
                                             ('current [A]', CCOL)))

        row += rowspan
        insertlabelrow(self.root, row, col, ('time [s]:', ))
        self.dvartime = DoubleVar()
        self.dvarvoltage = DoubleVar()
        self.dvarcurrent = DoubleVar()
        insertentryrow(
            self.root, row, col,
            (None, self.dvartime, self.dvarvoltage, self.dvarcurrent))
        col += TABLECOL
        Button(self.root, text="Insert",
               command=self.butcmdinsert).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)

        row += rowspan
        col = COL1
        insertlabelrow(self.root, row, col, ('step :', ))
        self.ivarstep = IntVar()
        insertentryrow(
            self.root, row, col,
            (None, self.ivarstep, self.dvarvoltage, self.dvarcurrent))
        col += TABLECOL
        Button(self.root, text="Modify",
               command=self.butcmdmodify).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)
        col += colspan
        Button(self.root, text="Delete",
               command=self.butcmddelete).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)

        row += rowspan
        col = COL1
        insertlabelrow(self.root, row, col, ('pause [s]:', ))
        self.dvarpause = DoubleVar()
        insertentryrow(
            self.root, row, col,
            (None, self.dvarpause, self.dvarvoltage, self.dvarcurrent))
        col += TABLECOL
        Button(self.root, text="Append",
               command=self.butcmdappend).grid(row=row,
                                               column=col,
                                               sticky=E + W,
                                               padx=8)

        self.clipboard = Clipboard(self.root, self.datawve, self.updateview,
                                   TABLEROW + 2, COL1)

        col = COL1 + TABLECOL
        colspan = 1
        row = TABLEROW + 1 + SCOPEROWSPAN
        Button(self.root, text="Help",
               command=self.btncmdhelp).grid(row=row,
                                             column=col,
                                             sticky=E + W,
                                             padx=8)
        col += 1
        Button(self.root, text="Done",
               command=self.butcmddone).grid(row=row,
                                             column=col,
                                             sticky=E + W,
                                             padx=8)

        self.scope.update()
        self.scope.redraw()
Exemplo n.º 13
0
    kh = KeyHandler(display)

    if arguments['copy']:
        # Copy from focused window
        copy_from_focused()
    elif arguments['paste']:
        # Paste to focused window
        paste_to_focused()
    elif arguments['focused']:
        # Print focused window id
        print(get_focused().id)
    elif arguments['daemon']:
        # Start daemon
        from clipboard import Clipboard
        Clipboard().run()
    elif arguments['history']:
        # print history?
        pass

# --------- Automate mouse clicks:
# import time
# from Xlib import X
# from Xlib.display import Display
# from Xlib.ext import xtest
# d=Display()
# def click(b):
#     xtest.fake_input(d.get_input_focus().focus, X.ButtonPress, b)
#     d.flush()
#     d.sync()
#     xtest.fake_input(d.get_input_focus().focus, X.ButtonRelease, b)
Exemplo n.º 14
0
 def clearSourceOfItemsToPaste(self):
     Clipboard().clear()
Exemplo n.º 15
0
 def restoreItemsToPasteToSource(self):
     Clipboard().put(self.__itemsToPaste, self.__sourceOfItemsToPaste)
Exemplo n.º 16
0
 def getItemsToPaste(self):
     items, source = Clipboard().get()
     return [item.copy() for item in items], source
Exemplo n.º 17
0
import cv2
import numpy as np

from vision import Vision
from controller import Controller
from keyboard import Keyboard
from clipboard import Clipboard

from game import Game

vision = Vision()
controller = Controller()
keyboard = Keyboard()
clipboard = Clipboard()
game = Game(vision, controller, keyboard, clipboard)

from pynput.keyboard import Key, Listener


#defining function to print when key is pressed
def on_press(key):
    pass
#print('{0} pressed'.format(key))


#defining function to print when key is released
def on_release(key):
    #print('{0} release'.format(key))
    if key == Key.esc:
        # Stop listener
        return False
Exemplo n.º 18
0
 def __putItemsOnClipboard(self):
     cb = Clipboard()
     self.__previousClipboardContents = cb.get(
     )  # pylint: disable-msg=W0201
     cb.put(self.items, self.list)