Пример #1
0
 def _layout_primerDesign_line2(self):
     check_species = Frame(self.options)
     check_species.pack(fill = X, pady = 5)
     
     sp = Label(check_species, text = 'Species:', 
                font = ("Arial", 10), width = 6)
     sp.pack(side = LEFT)
     
     self.species_var = StringVar()
     self.species_var.set(1)
     Issp = Radiobutton(check_species, text = "S. pombe", 
                        variable = self.species_var, value = "P")
     Issp.bind("<Button-1>", self._getfocusback)
     Issp.pack(side = LEFT)
     Issj = Radiobutton(check_species, text = "S. japonicus", 
                        variable=self.species_var, value = "J")
     Issj.bind("<Button-1>", self._getfocusback)
     Issj.pack(side = LEFT)
     Issc = Radiobutton(check_species, text = "S. cryophilus", 
                        variable = self.species_var, value = "C")
     Issc.bind("<Button-1>", self._getfocusback)
     Issc.pack(side = LEFT)
     Isso = Radiobutton(check_species, text = "S. octosporus", 
                        variable = self.species_var, value = "O")
     Isso.bind("<Button-1>", self._getfocusback)
     Isso.pack(side = LEFT)
Пример #2
0
 def _layout_primerDesign_line4_2(self):
     self.check_Ntag = Frame(self.options)
     self.check_Ntag.pack(after = self.check_mode, pady = 5)
     self.check_Ntag.forget()
     
     nt = Label(self.check_Ntag, text = 'N-terminal Tag:', 
                font = ("Arial", 10), width = 10)
     nt.pack(side = LEFT)
     
     self.Ntag_var = StringVar()
     self.Ntag_var.set(' ')
     Isnone = Radiobutton(self.check_Ntag, text = "None", 
                        variable = self.Ntag_var, value = ' ')
     Isnone.bind("<Button-1>", self._getfocusback)
     Isnone.pack(side=LEFT)
     Is3HA = Radiobutton(self.check_Ntag, text = "3HA", 
                       variable = self.Ntag_var, value = '3HA')
     Is3HA.bind("<Button-1>", self._getfocusback)
     Is3HA.pack(side = LEFT)
     IsGST = Radiobutton(self.check_Ntag, text = "GST", 
                       variable = self.Ntag_var, value = 'GST')
     IsGST.bind("<Button-1>", self._getfocusback)
     IsGST.pack(side = LEFT)
     IsGFP = Radiobutton(self.check_Ntag, text = "GFP", 
                         variable = self.Ntag_var, value = 'GFP')
     IsGFP.bind("<Button-1>", self._getfocusback)
     IsGFP.pack(side = LEFT)
Пример #3
0
 def _layout_primerDesign_line4_1(self):
     self.blankframe = Frame(self.options)
     self.blankframe.pack(after = self.check_mode, pady = 18)
     
     self.check_plsmd = Frame(self.options)
     self.check_plsmd.pack(after = self.check_mode, pady = 5)
     self.check_plsmd.forget()
     
     pl = Label(self.check_plsmd, text = 'Plasmid:', 
                font = ("Arial", 10), width = 10)
     pl.pack(side = LEFT)
     self.plasmid_var = StringVar()
     self.plasmid_var.set(3)
     IspFA6a = Radiobutton(self.check_plsmd, text = "pFA6a", 
                           variable = self.plasmid_var, value = 'pFA6a')
     IspFA6a.bind("<Button-1>", self._getfocusback)
     IspFA6a.pack(side = LEFT)
     IsKS = Radiobutton(self.check_plsmd, text = "KS-ura4", 
                        variable = self.plasmid_var, value = 'KS-ura4')
     IsKS.bind("<Button-1>", self._getfocusback)
     IsKS.pack(side = LEFT)
Пример #4
0
 def _layout_blast_line1(self):
     # BLAST species selection
     b_species = Frame(self.blast)
     b_species.pack(pady = 5, fill = X)
     
     bspl = Label(b_species, 
                  text = "Target pecies:", 
                  font = ("Arial", 10), width = 10)
     self.bsp_var = StringVar()
     self.bsp_var.set(5)
     bIssj = Radiobutton(b_species, 
                         text = "S. japonicus", 
                         variable = self.bsp_var, value = "J")
     bIssj.bind("<Button-1>", self._focusB)
     bIssc = Radiobutton(b_species, 
                         text = "S. cryophilus", 
                         variable = self.bsp_var, value = "C")
     bIssc.bind("<Button-1>", self._focusB)
     bIsso = Radiobutton(b_species, 
                         text = "S. octosporus", 
                         variable = self.bsp_var, value = "O")
     bIsso.bind("<Button-1>", self._focusB)
     bIsso.pack(side = RIGHT)
     bIssc.pack(side = RIGHT)
     bIssj.pack(side = RIGHT)
     bspl.pack(side = RIGHT)
Пример #5
0
    def create_radiobutton(self):
        P0, widget_dims, board_dims = self.board.get_geometry()
        x, y = P0
        width, height = widget_dims
        board_width, board_height = board_dims

        x, y = x / board_width, y / board_height
        width, height = width / board_width, height / board_height

        button = Radiobutton(self.board)
        button.place(relx=x, rely=y, relheight=height, relwidth=width, anchor="nw")
        self.board.delete("line")
        items = [item for item in button.keys() if len(item) > 2]

        button.bind("<Enter>", lambda event: self.get_widget_info(button))
        button.bind("<Leave>", lambda event: self.focus_out())
        button.bind("<Button-3>", lambda event: self.modify(button, items))

        self.manager.switch(button, items)
Пример #6
0
 def _layout_primerDesign_line3(self):
     self.check_mode = Frame(self.options)
     self.check_mode.pack(fill = X, pady = 5)
     
     self.mode_var = StringVar()
     self.mode_var.set(2)
     md = Label(self.check_mode, text = 'Fuction:', 
                font = ("Arial", 10), width = 6)
     md.pack(side = LEFT)
     Isdel = Radiobutton(self.check_mode,text = "Deletion", 
                         variable = self.mode_var, value="del", 
                         command = self._choose_plasmid)
     Isdel.bind("<Button-1>", self._getfocusback)
     Isdel.pack(side = LEFT)
     IsC = Radiobutton(self.check_mode, text = "C-terminal Tagging", 
                       variable = self.mode_var, value = "C", 
                       command = self._choose_Ctag)
     IsC.bind("<Button-1>", self._getfocusback)
     IsC.pack(side = LEFT)
     IsN = Radiobutton(self.check_mode, text = "N-terminal promoter adding", 
                       variable = self.mode_var, value = "N", 
                       command = self._choose_Ntag)
     IsN.bind("<Button-1>", self._getfocusback)
     IsN.pack(side = LEFT)
Пример #7
0
class CompetitorRegistrationWindow(Toplevel):
    def __init__(self, parent, db, *args, **kwargs):
        Toplevel.__init__(self, *args, **kwargs)
        self.parent = parent
        self.db = db
        self.title('Register new competitor...')
        self.hr1 = Frame(self, height=1, width=500, bg="gray")  # creates a gray line under the registration

        self.fnameLabel = Label(self, text='First:')
        self.lnameLabel = Label(self, text='Last:')
        self.levelLabel = Label(self, text='Level:')
        self.sexLabel = Label(self, text='Sex:')
        self.ageLabel = Label(self, text='Age:')

        self.sexValue = StringVar()
        self.sexValue.set('M')

        self.levelValues = ('Beginner', 'Intermediate', 'Advanced', 'Open')

        self.fnameEntry = EntryWithPlaceholder(self, placeholder='John', width=30)
        self.lnameEntry = EntryWithPlaceholder(self, placeholder='Doe', width=30)
        self.levelEntry = Spinbox(self, values=self.levelValues)
        self.sexEntryM = Radiobutton(self, text='M', variable=self.sexValue, value='M')
        self.sexEntryF = Radiobutton(self, text='F', variable=self.sexValue, value='F')
        self.ageEntry = Spinbox(self, from_=1, to=100, width=6)
        self.registerButton = Button(self, text='Register', command=self.register_competitor)

        self.ageEntry.delete('0', 'end')
        self.ageEntry.insert(0, 20)

        self.fnameEntry.bind('<Return>', self.register_competitor)  # these bind all the entries to <return>
        self.lnameEntry.bind('<Return>', self.register_competitor)  # meaning that hitting enter while within any of
        self.levelEntry.bind('<Return>', self.register_competitor)  # of them will submit the form to the
        self.sexEntryF.bind('<Return>', self.register_competitor)  # register_competitor function
        self.sexEntryM.bind('<Return>', self.register_competitor)
        self.ageEntry.bind('<Return>', self.register_competitor)
        self.registerButton.bind('<Return>', self.register_competitor)

        self.fnameLabel.grid(row=1, column=0)
        self.fnameEntry.grid(row=1, column=1, columnspan=4)
        self.lnameLabel.grid(row=1, column=5)
        self.lnameEntry.grid(row=1, column=6, columnspan=4)
        self.levelLabel.grid(row=2, column=0)
        self.levelEntry.grid(row=2, column=1, columnspan=2)
        self.sexLabel.grid(row=2, column=3)
        self.sexEntryM.grid(row=2, column=4)
        self.sexEntryF.grid(row=2, column=5)
        self.ageLabel.grid(row=2, column=6)
        self.ageEntry.grid(row=2, column=7)
        self.registerButton.grid(row=2, column=8)

    def register_competitor(self, *args):
        self.db.insert_row((self.fnameEntry.get(),
                            self.lnameEntry.get(),
                            self.levelEntry.get(),
                            self.sexValue.get(),
                            self.ageEntry.get(),
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
        self.clear_registration()
        self.fnameEntry.focus_set()

    def clear_registration(self):
        self.fnameEntry.replace_placeholder()
        self.lnameEntry.replace_placeholder()
        self.levelEntry.setvar(self.levelValues[0], value='1')
        self.sexValue.set('M')
        self.ageEntry.delete(0, 'end')
        self.ageEntry.insert(0, 20)
Пример #8
0
    def __init__(self,
                 main_window,
                 title,
                 prompt,
                 options,
                 customise_option=False,
                 text_placeholder="",
                 **kwargs):
        """
        Parameters
        ----------
        main_window : Program
            Program object which is the main window
            
        title : str
            Title of prompt window
            
        prompt : str
            Prompt text in dialog window
            
        options : list[str]
            List of options that will be displayed in multiple choice prompt
            
        customise_option : bool
            Logic to add option that includes text widget where user can type (default is False)
            
        text_placeholder : str
            Grey placeholder text in text widget (default = "")
        """
        super().__init__(**kwargs)
        self.title(title)
        self.customise_value = len(options)
        self.main = main_window
        self.text_placeholder = text_placeholder
        self.protocol("WM_DELETE_WINDOW", self._exit)

        prompt_frame = Frame(self)
        prompt_frame.pack(side="top")
        prompt_frame.bind("<ButtonRelease-1>", self._text_focus_off)

        prompt_message = Label(prompt_frame, text=prompt)
        prompt_message.pack(pady=(20, 10), padx=20)

        self.radio_frame = Frame(self)
        self.radio_frame.pack(anchor="c", fill="x", padx=50)
        self.radio_frame.bind("<ButtonRelease-1>", self._text_focus_off)

        self.v = IntVar()
        for i, option in enumerate(options):
            radio_button = Radiobutton(self.radio_frame,
                                       text=option,
                                       variable=self.v,
                                       value=i)
            radio_button.bind("<ButtonRelease-1>", self._text_focus_off)
            radio_button.pack(anchor="w", padx=20, pady=10)

        if customise_option:
            radio_button = Radiobutton(self.radio_frame,
                                       text="Customise",
                                       variable=self.v,
                                       value=self.customise_value)
            radio_button.pack(anchor="w", padx=20, pady=10)

            self.customise_text = TextWithPlaceholder(self.radio_frame,
                                                      self.text_placeholder,
                                                      height=2,
                                                      width=40)
            self.customise_text.bind("<ButtonRelease-1>", self._text_on_click)
            self.customise_text.pack(anchor="w", padx=(40, 40), pady=(0, 20))

        self.v.set(0)  #Set default selected radio button

        self.error_message_frame = Frame(self)
        self.error_message_frame.pack(anchor="c", fill="x")

        ok_button = Button(self,
                           text="OK",
                           width=20,
                           command=self._get_input_leaves)
        ok_button.pack(pady=(20, 20))
Пример #9
0
Файл: main.py Проект: kr1/roqba
    def create_voices(self):
        voice_ids = ['1', '2', '3', '4']
        SCALES = OrderedDict([
                  ('pan_pos', {'min': -1, 'max': 1, 'start': 0.5, 'res': 0.001}),
                  ('volume', {'min': 0, 'max': 1, 'start': 0.666, 'res': 0.001}),
                  ('slide_duration_msecs', {'min': 0, 'max': 2000, 'start': 60, 'res': 1}),
                  ('slide_duration_prop', {'min': 0, 'max': 2, 'start': 0.666, 'res': 0.001}),
                  ('binaural_diff', {'min': 0, 'max': 66, 'start': 0.2, 'res': 0.01})
                ])

        for vid in voice_ids:
            counter = 0
            for sca in SCALES:
                name = 'voice_' + vid + '_' + sca
                setattr(self, 'min_' + name, SCALES[sca]['min'])
                setattr(self, 'max_' + name, SCALES[sca]['max'])
                this_sca = Scale(self, label=sca, orient=HORIZONTAL,
                                 from_=getattr(self, 'min_' + name),
                                 to=getattr(self, 'max_' + name),
                                 resolution=SCALES[sca]['res'])
                this_sca.enable = ('enable' in list(SCALES[sca].keys()) and
                                   SCALES[sca]['enable'] or None)
                this_sca.disable = ('disable' in list(SCALES[sca].keys()) and
                                    SCALES[sca]['disable'] or None)
                this_sca.grid(column=int(2 + int(vid)), row=counter, sticky=E + W)
                this_sca.bind("<ButtonRelease>", self.scale_handler)
                this_sca.ref = name
                counter += 1
        CHECK_BUTTONS = OrderedDict(
                 [('mute', False),
                  ('automate_binaural_diffs', True),
                  ('automate_note_duration_prop', True),
                  ('use_proportional_slide_duration', {'val': True, 'label': 'proportional slide'}),
                  ('automate_pan', True),
                  ('automate_wavetables', True)])
        for vid in voice_ids:
            counter = 0
            cb_frame = LabelFrame(self, text="Voice {0} - Automation".format(vid))
            setattr(self, 'voice_' + vid + '_cb_frame', cb_frame)
            for cb in CHECK_BUTTONS:
                options = CHECK_BUTTONS[cb]
                name = 'voice_' + vid + '_' + cb
                if isinstance(options, dict) and 'label' in list(options.keys()):
                    label = options['label']
                else:
                    label = cb[9:] if cb[:9] == 'automate_' else cb
                setattr(self, name, IntVar(
                    value=type(options) == dict and options['val'] or options))
                self.this_cb = Checkbutton(cb_frame, text=label, variable=getattr(self, name))
                self.this_cb.bind('<Button-1>', self.check_boxes_handler)
                self.this_cb.disable = None
                self.this_cb.grid(sticky=W, column=0, row=counter)
                self.this_cb.ref = name
                counter += 1
            # add trigger wavetable-button
            trigWavetableButton = Button(cb_frame, text='Next Wavetable')
            trigWavetableButton.bind('<Button-1>', self.trigger_waveform_handler)
            trigWavetableButton.ref = 'voice_' + vid + "_trigger_wavetable"
            trigWavetableButton.grid(row=counter)
            cb_frame.grid(column=int(vid) + 2, row=5, sticky=E + W + N, rowspan=8)
        for vid in voice_ids:
            generation_types = ["random", "random_harmonic", "harmonic"]
            partial_pools = ["even", "odd", "all"]
            prefix = 'voice_' + vid + '_'
            types_name = prefix + 'wavetable_generation_type'
            pools_name = prefix + 'partial_pool'
            setattr(self, types_name, StringVar())
            getattr(self, types_name).set("random")
            setattr(self, pools_name, StringVar())
            getattr(self, pools_name).set("all")
            target_frame = getattr(self, 'voice_' + vid + '_cb_frame')
            gen_typ_frame = LabelFrame(target_frame, text="type")
            gen_typ_frame.grid(row=len(target_frame.winfo_children()), sticky=W)
            for gen_t in generation_types:
                gen_t_entry = Radiobutton(gen_typ_frame, value=gen_t, text=gen_t, anchor=W,
                                          variable=getattr(self, types_name))
                gen_t_entry.bind('<ButtonRelease-1>', self.wt_handler)
                gen_t_entry.ref = types_name
                gen_t_entry.grid(row=len(gen_typ_frame.winfo_children()), sticky=W)
            pp_frame = LabelFrame(target_frame, text="harmonics")
            for pp in partial_pools:
                pp_entry = Radiobutton(pp_frame, value=pp, text=pp, anchor=W,
                                       variable=getattr(self, pools_name))
                pp_entry.bind('<ButtonRelease-1>', self.wt_handler)
                pp_entry.ref = pools_name
                pp_entry.grid(row=len(pp_frame.winfo_children()), sticky=E + W)
            this_num_partials = Scale(pp_frame, label='number of harmonics', orient=HORIZONTAL,
                                      from_=1, to=24, resolution=1)
            this_num_partials.ref = prefix + 'num_partials'
            this_num_partials.grid(column=0, row=len(pp_frame.winfo_children()), sticky=E + W)
            this_num_partials.bind("<ButtonRelease>", self.scale_handler)
            pp_frame.grid(row=len(target_frame.winfo_children()), sticky=E + W)
    def __init__(self, parentwin, kvgrouppairs, flyoverfn):
        # CSV Generation options radio button
        self.master = parentwin
        self.kvgrouppairs = kvgrouppairs
        self.flyoverfn = flyoverfn

        # first radio group; note that command= callback is not needed. add it if you want to process clicks as they happen. my app just gets the state from vars
        Radiobutton(parentwin,
                    text="All Files",
                    variable=kvgrouppairs['DumpOptions'],
                    value=1).grid(row=2, column=4,
                                  sticky=W)  #command=self.MGradiogroup_fn,
        Radiobutton(parentwin,
                    text="Exclude Dups",
                    variable=kvgrouppairs['DumpOptions'],
                    value=2).grid(row=2, column=5,
                                  sticky=W)  #command=self.MGradiogroup_fn,
        Radiobutton(parentwin,
                    text="Only Dups",
                    variable=kvgrouppairs['DumpOptions'],
                    value=3).grid(row=2, column=6,
                                  sticky=W)  #command=self.MGradiogroup_fn,
        # second radio grou- which databases to operate on
        Radiobutton(parentwin,
                    text="All DBs",
                    variable=kvgrouppairs['DBOptions'],
                    value=1).grid(row=4, column=4, sticky=W)
        Radiobutton(parentwin,
                    text="Only in selected DB",
                    variable=kvgrouppairs['DBOptions'],
                    value=2).grid(row=4, column=5, sticky=W)
        Radiobutton(parentwin,
                    text="Not in selected DB",
                    variable=kvgrouppairs['DBOptions'],
                    value=3).grid(row=4, column=6, sticky=W)
        # third radio group
        #init the db from file or folder  radio button)
        rb1 = Radiobutton(parentwin,
                          text="Load\nCSV",
                          variable=self.kvgrouppairs['CsvOrLive'],
                          value=1)  #command=self.inittypeFn,
        rb1.grid(row=1, column=5, sticky=W)
        rb2 = Radiobutton(parentwin,
                          text="Scan\nTree",
                          variable=self.kvgrouppairs['CsvOrLive'],
                          value=2)  #, command=self.inittypeFn
        rb2.grid(row=1, column=6, sticky=W)
        rb1.bind(
            "<Enter>", lambda event: self.flyoverfn(
                "Choose LOAD CSV to load memory database from an existing .CSV file database (dumped from previous filesystem scan)\n"
                +
                "This may be useful for checking a new filesystem against your existing set of files where:\n"
                +
                "  a) you don't want to RE-scan your base files which may be huge list and take hours\n"
                +
                "  b) you don't have direct access to the backup, or it is very slow network access"
            ))
        rb1.bind("<Leave>", lambda event: self.flyoverfn(None))
        rb2.bind(
            "<Enter>", lambda event: self.flyoverfn(
                "Choose SCAN TREE to load memory database from a target filesystem in the current system\n\n\n"
            ))
        rb2.bind("<Leave>", lambda event: self.flyoverfn(None))

        # fourth radio group choose to COPY Unique files to a destination or to DELETE dups from a source!
        #
        rb1 = Radiobutton(parentwin,
                          text="Copy unique files",
                          variable=self.kvgrouppairs['DeleteInsteadofCopy'],
                          value=False)  #command=self.inittypeFn,
        rb1.grid(row=3, column=5, sticky=W)
        rb2 = Radiobutton(parentwin,
                          text="Delete DUPs in source",
                          variable=self.kvgrouppairs['DeleteInsteadofCopy'],
                          value=True)  #, command=self.inittypeFn
        rb2.grid(row=3, column=6, sticky=W)
        rb1.bind(
            "<Enter>", lambda event: self.flyoverfn(
                "Choose Choose COPY to write unique files to a new target folder (i.e. build a NEW, cleaner file tree)\n"
                +
                "Choose DELETE to delete duplicate files in a current database (i.e. clean the current files tree\n"
                +
                "  a) you don't want to RE-scan your base files which may be huge list and take hours\n"
                +
                "  b) you don't have direct access to the backup, or it is very slow network access"
            ))
        rb1.bind("<Leave>", lambda event: self.flyoverfn(None))
        rb2.bind(
            "<Enter>", lambda event: self.flyoverfn(
                "Choose DELETE to delete duplicate files in a current database (i.e. clean the current files tree\n\n\n"
            ))
        rb2.bind("<Leave>", lambda event: self.flyoverfn(None))
Пример #11
0
class UserInterface:
    def promotionRadioBttnFalse(self, event):

        self.promotion = "false"
        #print("Promotion = ", self.promotion)

    def promotionRadioBttnTrue(self, event):

        self.promotion = "true"
        #print("Promotion = ", self.promotion)

    def startTheModelButton(self, event):

        self.stopEvent = threading.Event()
        self.thread1 = threading.Thread(target=self.startModel, args=())
        self.thread1.start()

    def shopID(self, shop):

        self.shop = shop
        #print("Shop Chosen = ", self.shop)

    def productID(self, product):

        self.product = product
        #print("Product Chosen = ", self.product)

    def __init__(self, master):

        ##-------------------------- Setting up the variables --------------------------##

        self.master = master

        self.thread1 = None
        self.stopEvent = None

        self.shop_dd_options = [
            "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
        ]
        self.product_dd_options = [
            "108701", "99197", "103665", "105574", "106716", "114790",
            "115267", "115850", "116018", "119141"
        ]

        self.variable_shop = StringVar(self.master)
        self.variable_shop.set("Shop ID Drop Down")

        self.variable_product = StringVar(self.master)
        self.variable_product.set("Product ID Drop Down")

        self.shop_dd = OptionMenu(self.master,
                                  self.variable_shop,
                                  *self.shop_dd_options,
                                  command=self.shopID)

        self.product_dd = OptionMenu(self.master,
                                     self.variable_product,
                                     *self.product_dd_options,
                                     command=self.productID)

        self.mydate = StringVar(self.master)
        self.date = tk.Entry(self.master, textvariable=self.mydate, width=10)

        self.v = IntVar()
        self.onpromotion_false = Radiobutton(self.master,
                                             text="Promotion False",
                                             variable=self.v,
                                             value=0)
        self.onpromotion_true = Radiobutton(self.master,
                                            text="Promotion True",
                                            variable=self.v,
                                            value=1)

        self.output_quantity = Label(self.master, text="xxxx")
        self.shop_dd_label = Label(self.master,
                                   text="Please Select the Shop ID")
        self.product_dd_label = Label(self.master,
                                      text="Please Select the Product ID")
        self.date_dd_label = Label(self.master,
                                   text="Enter the Date : DD/MM/YYYY")
        self.output_dd_label = Label(self.master, text="Output Quantity is : ")

        self.name1 = Label(self.master, text="Shamsheer Verma : 12851248")
        self.name2 = Label(self.master, text="Ankit Kapoor : 12982233")
        self.name3 = Label(self.master, text="Avinash Pakanati: 12723514")

        self.start = Button(self.master,
                            text="START THE MODEL",
                            bg='white',
                            fg='black')

        ##-------------------------- Positioning the Drop Down, Input Box, RadioButtons, and Output --------------------------##

        self.onpromotion_false.config(height=1, width=28)
        self.onpromotion_true.config(height=1, width=25)
        self.shop_dd.config(height=1, width=20)
        self.product_dd.config(height=1, width=20)
        self.output_quantity.config(height=1, width=20)
        self.start.config(height=1, width=20)
        self.shop_dd_label.config(height=1, width=30)
        self.product_dd_label.config(height=1, width=30)
        self.date_dd_label.config(height=1, width=30)
        self.output_dd_label.config(height=1, width=20)
        self.name1.config(height=1, width=30)
        self.name2.config(height=1, width=30)
        self.name3.config(height=1, width=30)

        self.onpromotion_false.grid(row=1, column=0, sticky=W, pady=2)
        self.onpromotion_true.grid(row=1, column=1, sticky=E, pady=2)
        self.shop_dd.grid(row=2, column=1, sticky=E, pady=2)
        self.product_dd.grid(row=3, column=1, sticky=E, pady=2)
        self.date.grid(row=4, column=1, sticky=N, pady=2)
        self.output_quantity.grid(row=5, column=1, sticky=N, pady=2)
        self.shop_dd_label.grid(row=2, column=0, sticky=N, pady=2)
        self.product_dd_label.grid(row=3, column=0, sticky=N, pady=2)
        self.date_dd_label.grid(row=4, column=0, sticky=N, pady=2)
        self.output_dd_label.grid(row=5, column=0, sticky=N, pady=2)
        self.start.grid(row=6, column=0, sticky=N, pady=2, columnspan=2)
        self.name1.grid(row=9, column=0, sticky=S, pady=2)
        self.name2.grid(row=10, column=0, sticky=S, pady=2)
        self.name3.grid(row=11, column=0, sticky=S, pady=2)
        self.name1.place(x=1, y=240)
        self.name2.place(x=1, y=260)
        self.name3.place(x=1, y=280)

        self.uts_photo = PhotoImage(file="uts_logo_new.png")
        self.uts_logo = Label(self.master, image=self.uts_photo)
        self.uts_logo.image = self.uts_photo
        self.uts_logo.grid(row=8, column=0, sticky=N, pady=2, columnspan=2)
        self.uts_logo.place(x=270, y=240)

        self.start.bind("<Button-1>", self.startTheModelButton)
        self.onpromotion_false.bind("<Button-1>", self.promotionRadioBttnFalse)
        self.onpromotion_true.bind("<Button-1>", self.promotionRadioBttnTrue)

    ##-----------------------------Starting the Model - Machine Learning Algorithms - Over Here----------------------------##

    def sqlConnection(self):

        self.conn = pg.connect(host='localhost',
                               user="",
                               password="",
                               database="BIDS_Assignment_5")
        self.cur = self.conn.cursor()
        self.cur.execute("SELECT * FROM corporacion WHERE item_nbr = " +
                         self.product)

        self.colnames = [desc[0] for desc in self.cur.description]
        self.rows = self.cur.fetchall()

        self.subset = pd.DataFrame(self.rows)

        self.conn.close()

        self.subset.columns = self.colnames
        print(self.subset)
        print("done")

        self.subset.replace(to_replace="false", value=0, regex=True)
        self.subset.replace(to_replace="true", value=1, regex=True)

        self.subset.dropna(inplace=True, axis=0, how='any')

        self.current_year = now.year
        self.current_month = now.month
        self.current_day = now.day

        self.subset['date'] = pd.to_datetime(
            self.subset['date'], format='%Y-%m-%d')  #transforming date Column
        self.subset_year = self.subset['date'].dt.year
        self.subset_month = self.subset['date'].dt.month
        self.subset_day = self.subset['date'].dt.day
        self.subset['Duration'] = (
            (self.current_year * 365) +
            (self.current_month * 30) + self.current_day) - (
                (self.subset_year * 365) +
                (self.subset_month * 30) + self.subset_day)
        self.subset.drop('date', axis=1, inplace=True)
        self.randomForests()

    def randomForests(self):

        self.X_train, self.X_test, self.y_train, self.y_test = train_test_split(
            self.subset.drop(['id', 'unit_sales'], axis=1),
            self.subset['unit_sales'],
            test_size=0.3)

        self.lm = RandomForestRegressor(n_estimators=20)
        self.lm.fit(self.X_train, self.y_train)

        if self.promotion == 'true':
            self.promotiontf = 1
        else:
            self.promotiontf = 0

        #self.date = str(self.date)
        #print(datetime.now().date())
        #print(self.date)

        #print(self.date_input)
        self.rdate1 = datetime.strptime(self.date_input, "%Y%m%d").date()

        #print(self.rdate1)
        #self.rdate1 = strftime("%Y-%m-%d %H:%M:%S", str(self.date))
        self.duration = (datetime.now().date() - self.rdate1).days
        print(self.duration)
        self.mylist = {
            "date": self.duration,
            "store_nbr": self.shop,
            "item_nbr": self.product,
            "onpromotion": self.promotiontf
        }
        print(self.mylist)
        self.output_df = pd.DataFrame(self.mylist, index=[0])
        self.lm_predict = self.lm.predict(self.output_df)
        np.round(self.lm_predict, 0)
        self.output_quantity['text'] = self.lm_predict

    def startModel(self):

        self.date_input = str(eval(self.date.get()))

        print("clicking the button")
        print("Shop Number", self.shop)
        print("Product Number", self.product)
        print("Promotion True or False", self.promotion)
        print("Date", self.date_input)
        self.sqlConnection()