Ejemplo n.º 1
0
 def __init_clr_label(self, clr):
     """
     Gets the network ip, omitting the part after the last '.'
     
     Parameters
     ----------
     None
     
     Returns
     -------
     network: str
         The network ip
     """
     self.clr_label = tk.Label(self.clrLabFrame, bg=str(clr))
     self.clr_label.grid(column=0, row=0, padx=10, columnspan=2)
     self.clr_label.config(width=4)
     create_tooltip(self.clr_label, "Current colour")
Ejemplo n.º 2
0
 def __init_size_label(self, size):
     """
     Gets the network ip, omitting the part after the last '.'
     
     Parameters
     ----------
     None
     
     Returns
     -------
     network: str
         The network ip
     """
     self.size_label = tk.Label(self.sizeLabFrame,
                                text=str(size) + 'px',
                                bg='grey')
     self.size_label.pack(side='left', fill='both', padx=10)
     create_tooltip(self.size_label, "Current size")
Ejemplo n.º 3
0
 def __change_size(self, size=None, incr=None, decr=None):
     """
     Gets the network ip, omitting the part after the last '.'
     
     Parameters
     ----------
     None
     
     Returns
     -------
     network: str
         The network ip
     """
     self.dc.set_line_width(size=size, incr=incr, decr=decr)
     self.size_label.destroy()
     self.size_label = tk.Label(self.sizeLabFrame,
                                text=str(self.dc.line_width) + 'px',
                                bg='grey')
     self.size_label.pack(side='left', fill='both', padx=10)
     create_tooltip(self.size_label, "Current size")
     self.sizeScale.set(self.dc.line_width)
Ejemplo n.º 4
0
 def change_clr(self, button, clr):
     """
     Gets the network ip, omitting the part after the last '.'
     
     Parameters
     ----------
     None
     
     Returns
     -------
     network: str
         The network ip
     """
     self.dc.set_colour(colour=clr)
     self.clr_label.destroy()
     self.clr_label = tk.Label(self.clrLabFrame, bg=self.dc.line_clr)
     self.clr_label.grid(column=0, row=0, padx=10, columnspan=2)
     self.clr_label.config(width=4)
     create_tooltip(self.clr_label, "Current colour")
     for but in self.clr_buttons:
         but['state'] = tk.NORMAL
     button['state'] = tk.DISABLED
Ejemplo n.º 5
0
    def __init_size_buttons(self, controller):
        """
        Gets the network ip, omitting the part after the last '.'
        
        Parameters
        ----------
        None
        
        Returns
        -------
        network: str
            The network ip
        """
        self.sizeScale = tk.Scale(
            self.sizeLabFrame,
            command=self.set_size,
            bg='grey',
            troughcolor='grey',
            orient=tk.VERTICAL,
            showvalue=0,
            #label='Size',
            from_=99,
            to=1)
        self.sizeScale.pack(side='left', fill='both', padx=5)
        self.sizeScale.set(self.dc.line_width)
        create_tooltip(self.sizeScale, "Set the pen width")

        buttonPlus = tk.Button(self.sizeLabFrame,
                               text='+',
                               command=lambda: self.__change_size(incr=1),
                               bg='grey')
        buttonPlus.pack(side='top', fill='both', padx=10)
        create_tooltip(buttonPlus, "Increase pen size")

        buttonMin = tk.Button(self.sizeLabFrame,
                              text='-',
                              command=lambda: self.__change_size(decr=1),
                              bg='grey')
        buttonMin.pack(side='top', fill='both', padx=10)
        create_tooltip(buttonMin, "Decrease pen size")

        #buttonReset = tk.Button(self.sizeLabFrame, text='reset',
        #                        command=lambda : self.__change_size(size=2),
        #                        bg='grey')
        #buttonReset.pack(side='right', fill='both', padx=10)
        #create_tooltip(buttonReset, "Reset pen size")

        self.__init_size_label(size=2)
Ejemplo n.º 6
0
    def __init_clr_buttons(self, controller):
        """
        Gets the network ip, omitting the part after the last '.'
        
        Parameters
        ----------
        None
        
        Returns
        -------
        network: str
            The network ip
        """
        self.clr_buttons = []
        frameCol1 = tk.Frame(self.clrLabFrame, bg='grey')
        frameCol2 = tk.Frame(self.clrLabFrame, bg='grey')
        frameCol1.grid(column=0, row=1, pady=10)
        frameCol2.grid(column=1, row=1, pady=10)

        buttonColourLightgrey = tk.Button(
            frameCol1,
            text='lg',
            command=lambda: self.change_clr(buttonColourLightgrey,
                                            clr='lightgrey'),
            bg='lightgrey')
        buttonColourLightgrey.pack(side='top', fill='both')
        buttonColourLightgrey['state'] = tk.DISABLED
        self.clr_buttons.append(buttonColourLightgrey)
        create_tooltip(buttonColourLightgrey, "Set colour to light grey")

        buttonColourRed = tk.Button(
            frameCol2,
            text='r',
            command=lambda: self.change_clr(buttonColourRed, clr='red'),
            bg='red')
        buttonColourRed.pack(side='top', fill='both')
        self.clr_buttons.append(buttonColourRed)
        create_tooltip(buttonColourRed, "Set colour to red")

        buttonColourGreen = tk.Button(
            frameCol1,
            text='g',
            command=lambda: self.change_clr(buttonColourGreen, clr='green'),
            bg='green')
        buttonColourGreen.pack(side='top', fill='both')
        self.clr_buttons.append(buttonColourGreen)
        create_tooltip(buttonColourGreen, "Set colour to green")

        buttonColourBlue = tk.Button(
            frameCol2,
            text='b',
            command=lambda: self.change_clr(buttonColourBlue, clr='blue'),
            bg='blue')
        buttonColourBlue.pack(side='top', fill='both')
        self.clr_buttons.append(buttonColourBlue)
        create_tooltip(buttonColourBlue, "Set colour to blue")

        buttonColourYellow = tk.Button(
            frameCol1,
            text='y',
            command=lambda: self.change_clr(buttonColourYellow, clr='yellow'),
            bg='yellow')
        buttonColourYellow.pack(side='top', fill='both')
        self.clr_buttons.append(buttonColourYellow)
        create_tooltip(buttonColourYellow, "Set colour to yellow")

        buttonColourPurple = tk.Button(
            frameCol2,
            text='p',
            command=lambda: self.change_clr(buttonColourPurple, clr='purple'),
            bg='purple')
        buttonColourPurple.pack(side='top', fill='both')
        self.clr_buttons.append(buttonColourPurple)
        create_tooltip(buttonColourPurple, "Set colour to purple")

        buttonErase = tk.Button(
            self.clrLabFrame,
            text='Eraser',
            command=lambda: self.change_clr(buttonErase, clr=None),
            bg=None)
        buttonErase.grid(column=0, row=3, padx=10, columnspan=2, sticky='n')
        self.clr_buttons.append(buttonErase)
        create_tooltip(buttonErase, "Use the eraser")

        buttonSelClr = tk.Button(self.clrLabFrame,
                                 text='Select\ncolour',
                                 command=lambda: {self.select_clr()},
                                 bg='white')
        buttonSelClr.grid(column=0, row=2, padx=10, columnspan=2, sticky='n')
        self.clr_buttons.append(buttonSelClr)
        create_tooltip(buttonSelClr, "Select a custom colour")

        self.__init_clr_label(clr='lightgrey')
Ejemplo n.º 7
0
    def __init_style_buttons(self, controller):
        """
        Gets the network ip, omitting the part after the last '.'
        
        Parameters
        ----------
        None
        
        Returns
        -------
        network: str
            The network ip
        """
        self.style_buttons = []
        frameCol1 = tk.Frame(self.styleLabFrame, bg='grey')
        frameCol2 = tk.Frame(self.styleLabFrame, bg='grey')
        frameCol3 = tk.Frame(self.styleLabFrame, bg='grey')
        frameCol1.grid(column=0, row=1, pady=10)
        frameCol2.grid(column=1, row=1, pady=10)
        frameCol3.grid(column=0, row=2, columnspan=2, pady=10)

        self.style_options = {
            u'\u2015': 'pen',
            u'\u002D\u002D\u002D': 'dash',
            u'\u002E\u002E\u002E': 'dot',
            'A': 'text',
            u'\u25B2': 'triangle',
            u'\u25E3': 'triangleR',
            u'\u221F': 'graph',
            u'\u25A1': 'square',
            u'\u2B05': 'arrow'
        }

        styleslist = []
        for style in self.style_options.items():
            styleslist.append(style[0])

        self.styleComboBox = ttk.Combobox(frameCol3,
                                          values=styleslist,
                                          width=10,
                                          state='readonly')
        self.styleComboBox.pack(side='top', fill='both', padx=5)
        self.styleComboBox.set(styleslist[0])
        self.styleComboBox.bind('<<ComboboxSelected>>', lambda e:\
                           self.change_style(self.style_options[self.styleComboBox.get()]))
        #                   self.dc.set_draw_style(self.style_options[self.styleComboBox.get()]))

        buttonPen = tk.Button(
            frameCol1,
            text=(u'\u2015'),
            command=lambda: (
                self.change_style('pen'),
                #self.dc.set_draw_style('pen'),
                self.styleComboBox.set(u'\u2015')),
            bg='grey')
        buttonPen.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonPen)
        create_tooltip(buttonPen, "Set style to pencil")

        buttonDash = tk.Button(
            frameCol2,
            text=(u'\u002D\u002D\u002D'),
            command=lambda: (
                self.change_style('dash'),
                #self.dc.set_draw_style('dash'),
                self.styleComboBox.set(u'\u002D\u002D\u002D')),
            bg='grey')
        buttonDash.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonDash)
        create_tooltip(buttonDash, "Set style to dashes")

        buttonDot = tk.Button(
            frameCol1,
            text=(u'\u002E\u002E\u002E'),
            command=lambda: (
                self.change_style('dot'),
                #self.dc.set_draw_style('dot'),
                self.styleComboBox.set(u'\u002E\u002E\u002E')),
            bg='grey')
        buttonDot.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonDot)
        create_tooltip(buttonDot, "Set style to dots")

        buttonText = tk.Button(
            frameCol2,
            text='A',
            font=('Courier', 12, 'bold'),
            command=lambda: (
                self.change_style('text'),
                #self.dc.set_draw_style('text'),
                self.styleComboBox.set('A')),
            bg='grey')
        buttonText.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonText)
        create_tooltip(buttonText, "Set style to text typing")

        buttonTriangle = tk.Button(
            frameCol1,
            text=(u'\u25B2'),
            command=lambda: (
                self.change_style('triangle'),
                #self.dc.set_draw_style('triangle'),
                self.styleComboBox.set(u'\u25B2')),
            bg='grey')
        buttonTriangle.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonTriangle)
        create_tooltip(buttonTriangle, "Set style to acute triangles")

        buttonTriangleR = tk.Button(
            frameCol2,
            text=(u'\u25E3'),
            command=lambda: (
                self.change_style('triangleR'),
                #self.dc.set_draw_style('triangleR'),
                self.styleComboBox.set(u'\u25E3')),
            bg='grey')
        buttonTriangleR.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonTriangleR)
        create_tooltip(buttonTriangleR, "Set style to right triangles")

        buttonGraph = tk.Button(
            frameCol1,
            text=(u'\u221F'),
            command=lambda: (
                self.change_style('graph'),
                #self.dc.set_draw_style('graph'),
                self.styleComboBox.set(u'\u221F')),
            bg='grey')
        buttonGraph.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonGraph)
        create_tooltip(buttonGraph, "Set style to graph plotting")

        buttonSquare = tk.Button(
            frameCol2,
            text=(u'\u25A1'),
            command=lambda: (
                self.change_style('square'),
                #self.dc.set_draw_style('square'),
                self.styleComboBox.set(u'\u25A1')),
            bg='grey')
        buttonSquare.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonSquare)
        create_tooltip(buttonSquare, "Set style to rectangular drawing")

        buttonArrow = tk.Button(
            frameCol2,
            text=(u'\u2B05'),
            command=lambda: (
                self.change_style('arrow'),
                #self.dc.set_draw_style('arrow'),
                self.styleComboBox.set(u'\u2B05')),
            bg='grey')
        buttonArrow.pack(side='top', fill='both', padx=5)
        self.style_buttons.append(buttonArrow)
        create_tooltip(buttonArrow, "Set style to arrow drawing")
Ejemplo n.º 8
0
    def __init_shape_widgets(self, controller):
        """
        Gets the network ip, omitting the part after the last '.'
        
        Parameters
        ----------
        None
        
        Returns
        -------
        network: str
            The network ip
        """
        self.scale_drawing = tk.IntVar()
        scaleCheckButton = tk.Checkbutton(self.shapeCorLabFrame,
                                          text='Scale',
                                          variable=self.scale_drawing,
                                          onvalue=1,
                                          offvalue=0,
                                          command=self.toggle_scaling,
                                          bg='grey')
        scaleCheckButton.pack(side='top', fill='both', padx=5)
        if self.dc.scale_widg == False:
            self.scale_drawing.set(0)
        else:
            self.scale_drawing.set(1)
        create_tooltip(scaleCheckButton,
                       "Enable/Disable scaling on window resize")

        self.shape_correction = tk.IntVar()
        corrCheckButton = tk.Checkbutton(self.shapeCorLabFrame,
                                         text='Correct',
                                         variable=self.shape_correction,
                                         onvalue=1,
                                         offvalue=0,
                                         command=self.toggle_shape_correction,
                                         bg='grey')
        corrCheckButton.pack(side='top', fill='both', padx=5)
        create_tooltip(corrCheckButton, "Enable/Disable shape correction")

        if self.dc.correct == True:
            self.shape_correction.set(1)
        else:
            self.shape_correction.set(0)

        corrLnScale = tk.Scale(self.shapeCorLabFrame,
                               command=self.set_shape_corr_margin_ln,
                               bg='grey',
                               troughcolor='grey',
                               orient=tk.HORIZONTAL,
                               showvalue=0,
                               label='Line',
                               from_=1,
                               to=100)
        corrLnScale.pack(side='top', fill='both', padx=5)
        corrLnScale.set(self.dc.margin_line)
        create_tooltip(corrLnScale, "Set line correction sensitivity")

        corrCrclScale = tk.Scale(self.shapeCorLabFrame,
                                 command=self.set_shape_corr_margin_crcl,
                                 bg='grey',
                                 troughcolor='grey',
                                 orient=tk.HORIZONTAL,
                                 showvalue=0,
                                 label='Circle',
                                 from_=1,
                                 to=100)
        corrCrclScale.pack(side='top', fill='both', padx=5)
        corrCrclScale.set(self.dc.margin_circle)
        create_tooltip(corrCrclScale, "Set circle correction sensitivity")
Ejemplo n.º 9
0
    def __init_graph_widgets(self, controller):
        """
        Initialises the graph related widgets
        
        Parameters
        ----------
        controller:
            The controlling widget
        """
        fTop = tk.Frame(self.graphFrameLab, bg='grey')
        fTop.pack(side='top')
        fLeftTop = tk.Frame(fTop, bg='grey')
        fLeftTop.pack(side='left')
        fRightTop = tk.Frame(fTop, bg='grey')
        fRightTop.pack(side='left')

        fLeft = tk.Frame(self.graphFrameLab, bg='grey')
        fLeft.pack(side='left')
        fRight = tk.Frame(self.graphFrameLab, bg='grey')
        fRight.pack(side='left')

        xlabel = tk.Label(fLeftTop, text='x:', bg='grey')
        xlabel.pack(side='top', padx=10)

        self.xentry = Entry_w_Placeholder(fRightTop, placeholder='100, 300')
        self.xentry.pack(side='top', padx=10)

        ylabel = tk.Label(fLeftTop, text='y:', bg='grey')
        ylabel.pack(side='top', padx=10)

        self.yentry = Entry_w_Placeholder(fRightTop, placeholder='100, 200')
        self.yentry.pack(side='top', padx=10)

        self.periodScale = tk.Scale(fLeft,
                                    command=lambda e: (),
                                    bg='grey',
                                    troughcolor='grey',
                                    orient=tk.HORIZONTAL,
                                    label='Periods',
                                    from_=10,
                                    to=1)
        self.periodScale.pack(side='top', fill='both', padx=5)
        self.periodScale.set(1)
        create_tooltip(self.periodScale, "Set number of periods")

        freqLabel = tk.Label(fLeft, text='Frequency:', bg='grey')
        freqLabel.pack(side='top', fill='both', padx=5)
        self.freqEntry = Entry_w_Placeholder(fRight, placeholder='1')
        self.freqEntry.pack(side='top', fill='both', padx=5)
        create_tooltip(self.freqEntry, "Set frequency in Hz")

        sinFunc = lambda: (controller.call_function(
            member=DrawPage,
            function=DrawPage.callback_draw_sine,
            p1=self.convert_t_list(self.xentry.get().split(','), int),
            p2=self.convert_t_list(self.yentry.get().split(','), int),
            p3=self.periodScale.get(),
            p4=float(self.freqEntry.get())))

        buttonSine = tk.Button(self.graphFrameLab,
                               text='Sine wave',
                               command=sinFunc,
                               bg='grey')
        buttonSine.pack(side='top', fill='both', padx=10)
        create_tooltip(buttonSine, 'Creates a sine wave')

        cosFunc = lambda: (controller.call_function(
            member=DrawPage,
            function=DrawPage.callback_draw_cosine,
            p1=self.convert_t_list(self.xentry.get().split(','), int),
            p2=self.convert_t_list(self.yentry.get().split(','), int),
            p3=self.periodScale.get(),
            p4=float(self.freqEntry.get())))

        buttonCos = tk.Button(self.graphFrameLab,
                              text='Cosine wave',
                              command=cosFunc,
                              bg='grey')
        buttonCos.pack(side='top', fill='both', padx=10)
        create_tooltip(buttonCos, 'Creates a cosine wave')
Ejemplo n.º 10
0
    def init_password_widgets(self, controller):
        frame_left = tk.Frame(self.frame_password, bg=controller.clrs['main'])
        frame_right = tk.Frame(self.frame_password, bg=controller.clrs['main'])
        frame_left.pack(side='left', fill='both')
        frame_right.pack(side='right', fill='both')

        self.label_password = tk.Label(frame_left,
                                       text='Password',
                                       bg=controller.clrs['main'])
        self.label_password.pack(side='top', padx=10)

        self.result_password = tk.Entry(frame_left, bg=controller.clrs['main'])
        self.result_password.pack(side='top', padx=10)
        self.result_password.insert(0, ('*' * 8))
        #self.result_password = tk.Label(frame_left, text='********',
        #                               bg=controller.clrs['main'])
        #self.result_password.pack(side='top', padx=10)
        create_tooltip(
            self.result_password,
            text='The resulting password will be shown here if selected')

        self.hide_password = tk.IntVar()
        check_hide_password = tk.Checkbutton(frame_left,
                                             text='Hide password',
                                             variable=self.hide_password,
                                             onvalue=1,
                                             offvalue=0,
                                             bg=controller.clrs['main'])
        check_hide_password.pack(side='top', fill='both', padx=5)
        self.hide_password.set(1)
        create_tooltip(
            check_hide_password,
            text=
            'Toggle the password to be hidden. Does not refresh unless a password is generated.'
        )

        self.button_password = tk.Button(frame_left,
                                         text='Generate password',
                                         command=self.generate_password,
                                         bg=controller.clrs['button'])
        self.button_password.pack(side='top', fill='both', padx=10)
        create_tooltip(self.button_password, text='Generate a password')

        self.label_omit = tk.Label(frame_right,
                                   text='Characters to exclude:',
                                   bg=controller.clrs['main'])
        self.label_omit.pack(side='top', padx=10)
        self.entry_omit = tk.Entry(frame_right, bg=controller.clrs['main'])
        self.entry_omit.pack(side='top', padx=10)
        create_tooltip(
            self.entry_omit,
            text='Type (or paste) any characters here to omit from a password')

        self.label_length = tk.Label(frame_right,
                                     text='Length of the password',
                                     bg=controller.clrs['main'])

        self.label_length.pack(side='top', padx=10)
        self.entry_length = tk.Entry(frame_right, bg=controller.clrs['main'])
        self.entry_length.insert(0, '8')
        self.entry_length.pack(side='top', padx=10)

        self.mem_password = tk.IntVar()
        check_mem_password = tk.Checkbutton(frame_right,
                                            text='Create memorable password',
                                            variable=self.mem_password,
                                            onvalue=1,
                                            offvalue=0,
                                            bg=controller.clrs['main'])
        check_mem_password.pack(side='top', fill='both', padx=5)
        self.mem_password.set(0)
        self.label_mem = tk.Label(frame_right,
                                  text='Memorable phrase:',
                                  bg=controller.clrs['main'])
        self.label_mem.pack(side='top', padx=10)
        self.entry_mem = tk.Entry(frame_right, bg=controller.clrs['main'])
        self.entry_mem.pack(side='top', padx=10)