示例#1
0
    def _draw_class_selection_menu(self):
        '''
        Draw the drop down menu that is used to select which class is being
        currently annotated
          
        Parameters
        ----------
        None
        
        Attributes
        ----------
        selected_class : tkinter StringVar object
            This is the variable assigned to the object class selection drop
            down menu
        
        Raises
        ------
        None        
        
        Returns
        -------
        None
            
        '''

        self.root_app.selected_class = StringVar(self.toolbar_frame)
        self.root_app.selected_class.set(self.root_app.class_list[0])
        option_menu = OptionMenu(self.toolbar_frame,
                                 self.root_app.selected_class,
                                 *self.root_app.class_list)

        option_menu.place(x=60, y=5, width=100, height=40)
        def change_dropdown_newex(*args):

            if dir_data_path_train.get() != '':

                if popup_newex_var.get() == "New":

                    model_name.set("")

                    self.place_entry(cont_training, model_name, 333, 87, 33, 153)

                    text_mn = "Enter model name\n(without file extension)  "
                    self.place_text(cont_training, text_mn, 130, 90, 25, 200)

                else:

                    file_list = os.listdir(dir_data_path_train.get())
                    new_list = [i for i in file_list if ".hdf5" in i and not ".csv" in i]

                    if len(new_list) != 0:

                        self.place_text(cont_training, "Found the following model files  ", 140, 85, 35, 210)

                        model_name.set(new_list[0])
                        model_name_popupMenu = OptionMenu(cont_training, model_name, *set(new_list))
                        model_name_popupMenu.place(bordermode=OUTSIDE, x=335, y=87, height=35, width=150)

                        def change_dropdown(*args):
                            pass

                        model_name.trace('w', change_dropdown)

                    else:
                        self.place_text(cont_training, "No model found", 150, 90, 25, 150)
示例#3
0
class ChooseAlgorithmAndSpeed:
    def __init__(self, AlgoList):
        self.Algo = "BFS"
        self.Delay = 0
        self.root = Tk()

        self.Algo_Label = Label(master=self.root, text="Algorithm")
        self.Algo_Label.place(x=10, y=15)
        self.Choice = StringVar(self.root)
        self.Choice.set(AlgoList[0])
        self.Algo_Option = OptionMenu(self.root, self.Choice, *AlgoList)
        self.Algo_Option.place(x=80, y=10)

        self.Time_Label = Label(master=self.root, text="Frame delay")
        self.Time_Label.place(x=10, y=60)
        self.Time_Entry = Entry(master=self.root, width=4)
        self.Time_Entry.insert(0, "0.0")
        self.Time_Entry.place(x=100, y=60)

        OK_Button = Button(master=self.root,
                           text="RUN!",
                           width=3,
                           height=1,
                           command=self.Close)
        OK_Button.place(x=50, y=100)

        self.root.title("AI")
        self.root.wait_window()

    def Close(self):
        self.Algo = self.Choice.get()
        self.Delay = float(self.Time_Entry.get())
        self.root.destroy()
示例#4
0
 def create_OptionMenu(self, s, frame, val, loc, func):
     # Set figures variable and trace changes
     s.set(val)
     s.trace("w", self.change_option)
     om = OptionMenu(frame, s, *func)
     om.place(relx=loc, relwidth=0.15, relheight=1)
     om.config(bg="#2874A6")
     om["menu"]["bg"] = "#2874A6"
     om["activebackground"] = "#5499C7"
    def place_prediction_text(self, min_obj_size, batch_var, popupvar, window):

        text_entry = "Enter the minimum object size (in pixels) to filter out noise"
        self.place_text(window, text_entry, 20, 160, None, None)
        self.place_entry(window, min_obj_size, 30, 180, 35, 50)

        self.place_text(window, "Apply model prediction on one folder or multiple folders?", 20, 220,
                                 None, None)
        batch_var.set("One folder")
        popupmenu_batch_pred = OptionMenu(window, batch_var, *set(["One folder", "Multiple folders"]))
        popupmenu_batch_pred.place(bordermode=OUTSIDE, x=30, y=240, height=30, width=130)
        def askopendir():

            set_dir_data_path = filedialog.askdirectory(parent=data_root, title='Choose a directory')
            dir_data_path.set(set_dir_data_path)

            pr_list, val_List = self.preprocess.poss_tile_sizes(set_dir_data_path + os.sep + "train" + os.sep + "RawImgs")

            if set_dir_data_path != "":

                tkvar.set(list(pr_list)[0])  # set the default option
                choices = pr_list

                popupMenu = OptionMenu(data_root, tkvar, *choices)
                popupMenu.place(bordermode=OUTSIDE, x=30, y=90, height=30, width=300)
示例#7
0
    def classSelection(self, C):
        classSelection = []
        for i in self.classes:
            classSelection.append(i['name'])

        tk.Label(C, text="Choose a Class").place(relx=0.02, rely=0.08)
        self.classVar = tk.StringVar(C)
        self.classVar.set(classSelection[0])
        classMenu = OptionMenu(C,
                               self.classVar,
                               classSelection[0],
                               *classSelection[1:],
                               command=self.infoBoxPop)
        classMenu.pack()
        classMenu.place(relx=0.01, rely=0.1, width=130, height=30)
示例#8
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.Obj_Menu_Create_Team = controller
        self.container = controller.container
        tk.Label(self, text="ASSOCIER UNE ÉQUIPE À UN BUZZER").pack()
        tk.Label(
            self,
            text=
            "(L'ordre dans lequel les buzzers sont(0,1,2...),correspondra à l'ordre dans lequel vous avez appuyé les touches.)"
        ).pack()

        tk.Label(self, text="Buzzers:").place(x=70, y=70)
        longueur_y = 115
        self.list_variable_team = {}
        for n in range(0, (len(controller.list_team))):
            nom_buzz = "Buzz0{}".format(str(n))
            tk.Label(self, text=nom_buzz).place(x=45, y=longueur_y)
            variable_team = StringVar(self)
            variable_team.set(controller.list_team[n])  # default value
            self.list_variable_team[n] = variable_team

            drop_down_menu_team = OptionMenu(self, variable_team,
                                             *controller.list_team)
            drop_down_menu_team.pack()
            drop_down_menu_team.place(x=100, y=longueur_y)
            longueur_y += 55

        longueur_y += 30

        btn_liste_equipe = Button(self,
                                  text="Liste des équipes",
                                  command=controller.show_team)
        btn_liste_equipe.place(x=100, y=longueur_y)
        longueur_y += 38
        btn_revenir_menu = Button(self,
                                  text="revenir au menu principal",
                                  command=lambda: controller.switch_frame(
                                      controller.container,
                                      "Menu_Create_Team",
                                      controller=self.Obj_Menu_Create_Team))
        btn_revenir_menu.place(x=100, y=longueur_y)
        longueur_y += 38
        btn_jeu = Button(
            self,
            text="commencer le jeu",
            command=lambda: controller.switch_frame(
                controller.container, "Window_Detect_Winner", controller=self))
        btn_jeu.place(x=100, y=longueur_y)
        def askopendir_train():

            set_dir_data_path = filedialog.askdirectory(parent=cont_training, title='Choose a directory')
            dir_data_path_train.set(set_dir_data_path)

            mydata = Create_npy_files(dir_data_path_train.get())

            try:

                zero_perc, fg_bg_ratio = mydata.check_class_balance()

                text = "Average percentage of background pixels in augmented label data: " + str(round(zero_perc*100,2))
                place_text(cont_training, text, 30, 360, None, None)

                text2 = "Foreground to background pixel ratio: 1 to " + str(fg_bg_ratio) + " "*30
                place_text(cont_training, text2, 30, 380, None, None)

                popup_newex_var.set("New")
                popupMenu_new_ex = OptionMenu(cont_training, popup_newex_var, *set(["New", "Existing"]))
                popupMenu_new_ex.place(bordermode=OUTSIDE, x=30, y=90, height=30, width=100)

                weight_images = os.listdir(dir_data_path_train.get() + os.sep + "aug_weights")

                if len(weight_images) == 0:

                    place_text(cont_training, "No weight map images detected.", 30, 280, 30, 180)

                    use_weight_map.set(0)

                else:

                    use_weight_map.set(False)
                    Checkbutton(cont_training, text="Use weight map", variable=use_weight_map, onvalue=True,
                                offvalue=False).place(bordermode=OUTSIDE, x=30, y=250, height=30, width=120)

                    text_bs = "When using a weight map for training, use a lower batch size"
                    place_text(cont_training, text_bs, 30, 275, None, None)
                    place_text(cont_training, "to not overload your GPU/CPU memory", 30, 290, None, None)

                    place_text(cont_training, "Class balance weight factor", 30, 325, None, None)
                    place_entry(cont_training, balancer, 250, 320, 30, 50)

            except:

                text_er = "Error: Please choose the MitoSegNet Project directory"
                self.place_text(cont_training, text_er, 500, 30, 20, 380)
    def eval_train(self):

        analysis_root = Tk()
        self.new_window(analysis_root, "MitoSegNet Training Analysis", 450, 170)

        datapath = StringVar(analysis_root)
        popup_var = StringVar(analysis_root)

        # choose csv file window
        def askopencsv():
            set_modelpath = filedialog.askopenfilename(parent=analysis_root, title='Choose a CSV file')
            datapath.set(set_modelpath)

        #### browse for pretrained model
        text = "Select training log file"
        self.place_browse(askopencsv, text, datapath, 15, 20, None, None, analysis_root)

        popup_var.set("Accuracy")
        Label(analysis_root, text="Choose Metric to display", bd=1).place(bordermode=OUTSIDE, x=15, y=90)
        popupMenu_train = OptionMenu(analysis_root, popup_var, *set(["Accuracy", "Dice coefficient", "Loss"]))
        popupMenu_train.place(bordermode=OUTSIDE, x=15, y=110, height=30, width=150)

        # start analysis
        def analysis():

            if datapath.get() != "":

                analyser = AnalyseData()

                if popup_var.get() == "Accuracy":
                    metric = "acc"
                elif popup_var.get() == "Dice coefficient":
                    metric = "dice_coefficient"
                else:
                    metric = "loss"

                aut = False

                analyser.csv_analysis(datapath.get(), metric, popup_var.get(), aut)

            else:

                messagebox.showinfo("Error", "Entries not completed", parent=analysis_root)

        self.place_button(analysis_root, "Analyse", analysis, 300, 110, 30, 110)
示例#11
0
class Options:
    def __init__(self, master, title, data, x_coor, y_coor, width):

        self.__selected = StringVar()
        label = Label(master, text=title)
        label.config(font=("Calibri", 12))
        self.__selected.set(data[0])
        label.place(x=x_coor, y=y_coor, height=25, width=100)
        self.__option = OptionMenu(master, self.__selected, *data)
        self.__option.place(x=150, y=y_coor, height=25, width=width)

    def set_selected(self, data):
        self.__selected.set(data)

    def get_selected(self):
        return self.__selected.get()

    def update_data(self, data):
        self.__option.option_clear()
        self.__option.option_add(data, '')
        self.__option.update()
        def askopendir_pred():

            set_dir_data_path = filedialog.askdirectory(parent=cont_prediction_window, title='Choose a directory')
            dir_data_path_prediction.set(set_dir_data_path)

            if dir_data_path_prediction.get() != "":

                file_list = os.listdir(dir_data_path_prediction.get())
                new_list = [i for i in file_list if ".hdf5" in i and not ".csv" in i]

                if len(new_list) != 0:

                    found.set(1)

                    self.place_text(cont_prediction_window, "Found the following model files", 40, 60, 35, 190)

                    model_name.set(new_list[0])
                    model_name_popupMenu = OptionMenu(cont_prediction_window, model_name, *set(new_list))
                    model_name_popupMenu.place(bordermode=OUTSIDE, x=230, y=63, height=30, width=200)

                else:
                    self.place_text(cont_prediction_window, "No model found", 40, 60, 35, 360)
示例#13
0
class MyApp:
    def __init__(self):

        self.myContainer1 = tk.Tk()
        self.myContainer1.wm_attributes('-type', 'splash')
        self.myContainer1.title("Monsterrhino Printer")
        self.myContainer1.geometry("800x480")

        self.myContainer1.configure(bg="black")

        # Set up variables
        self.im_height = 1240  # Maximum step number of axis
        self.im_width = 2000  # Maximum step number of axis
        self.pix_per_step = 2

        self.pos = [0, 0, 0]
        self.ser = serial.Serial()
        self.ser.baudrate = 115200
        self.port_name = "/dev/ttyUSB0"

        self.laser_status = "off"
        self.laser_pin = 26
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.laser_pin, GPIO.OUT)
        self.laser(0)

        self.hight_factor = 0.66
        self.rot_count = 90
        self.homing = False
        # Show image
        self.tkpi = PhotoImage(file="images/monsterrhino.png")
        self.label = Label(self.myContainer1,
                           image=self.tkpi,
                           bg='black',
                           fg="white",
                           activebackground=HOVERCOLER,
                           borderwidth=0,
                           highlightbackground="black",
                           font="none 18")

        self.load_img = Button(self.myContainer1,
                               text="Load Image!",
                               command=self.new_img,
                               bg='black',
                               fg="white",
                               activebackground=HOVERCOLER,
                               borderwidth=2,
                               highlightbackground="black",
                               font="none 18")

        self.connect = Button(self.myContainer1,
                              text="X",
                              command=self.restart_app,
                              bg='black',
                              activebackground=HOVERCOLER,
                              borderwidth=2,
                              highlightbackground="black",
                              font="none 18",
                              fg="red")

        self.status_bar = Label(self.myContainer1, text="Status")

        self.spinnbox_label = Label(self.myContainer1,
                                    text="Image height:",
                                    bg='black',
                                    fg="white",
                                    activebackground=HOVERCOLER,
                                    borderwidth=2,
                                    highlightbackground="black",
                                    font="none 8")

        self.go_zero = Button(self.myContainer1,
                              text="Home",
                              command=self.home_xy_axis,
                              bg='black',
                              fg="white",
                              activebackground=HOVERCOLER,
                              borderwidth=2,
                              highlightbackground="black",
                              font="none 18")

        self.res_label = Label(self.myContainer1,
                               text="{}x{} px".format(self.im_height,
                                                      self.im_width),
                               bg='black',
                               fg="white",
                               activebackground=HOVERCOLER,
                               borderwidth=2,
                               highlightbackground="black",
                               font="none 8")

        self.burn = Button(self.myContainer1,
                           text="Start plotting!",
                           command=self.start_printing,
                           bg='black',
                           fg="white",
                           activebackground=HOVERCOLER,
                           borderwidth=2,
                           highlightbackground="black",
                           font="none 18")

        self.xdir_label = Label(self.myContainer1,
                                text="y_max = 1500 steps ------------> y",
                                bg='black',
                                fg="white",
                                activebackground=HOVERCOLER,
                                borderwidth=2,
                                highlightbackground="black",
                                font="none 8")
        self.rotate_img = Button(self.myContainer1,
                                 text="Rotate Image!",
                                 command=self.rotate_image)

        self.variable = StringVar(self.myContainer1)
        self.variable.set("700")  # default value
        self.drop_down = OptionMenu(self.myContainer1, self.variable, "500",
                                    "600", "700", "800", "900", "1000", "1100",
                                    "1200", "1300", "1400", "1500")
        self.drop_down.configure(bg='black',
                                 fg="white",
                                 activebackground=HOVERCOLER,
                                 borderwidth=2,
                                 highlightbackground="black",
                                 font="none 18")

        self.var1 = tk.IntVar()
        self.checkbox = tk.Checkbutton(self.myContainer1,
                                       text='Curved',
                                       variable=self.var1,
                                       onvalue=1,
                                       offvalue=0,
                                       bg='black',
                                       activebackground=HOVERCOLER,
                                       borderwidth=0,
                                       highlightbackground="black",
                                       font="none 18",
                                       fg="red")

        # Organize layout using grid
        self.label.place(x=520, y=440, anchor="s", height=430, width=500)
        self.load_img.place(x=140, y=90, anchor="s", height=80, width=240)
        self.spinnbox_label.place(x=100, y=115, anchor="s")
        self.drop_down.place(x=140, y=200, anchor="s", height=80, width=240)
        self.go_zero.place(x=140, y=285, anchor="s", height=80, width=240)
        self.burn.place(x=140, y=370, anchor="s", height=80, width=240)
        # self.checkbox.place(x=140, y=430, anchor="s")

        self.connect.place(x=770, y=50, anchor="s", height=40, width=40)

        self.xdir_label.place(x=140, y=470, anchor="s")
        # self.res_label.place(x=140, y=470, anchor="s")

        self.tc_receive_CAN_task = BackgroundTask(self.tc_receive_CAN)
        self.querry_y_pos_const_task = BackgroundTask(self.querry_y_pos_const)
        self.blink_led_task = BackgroundTask(self.blink_LED)
        self.print_task = BackgroundTask(self.draw_img_new)
        self.run = False

        if not PC:
            print("Startup CAN!")
            os.system("sudo /sbin/ip link set can0 up type can bitrate 1000000"
                      )  # brings up CAN
            self.can_bus = can.interface.Bus(bustype="socketcan",
                                             channel="can0",
                                             bitrate=1000000)
            time.sleep(0.1)

            # start receive task
            self.tc_receive_CAN_task.start()
            print("Start can querry task")

            self.led = LED()
            self.led.init_led()
            self.led.set_green()

        self.querry_y_pos_const_task.start()

    def start_printing(self):
        """Starts printing
        """
        self.print_task.start()

    def restart_app(self):
        """Restarts app, only from debugg area callable
        """
        os._exit(0)

    def tc_receive_CAN(self, par):
        """Starts receiver task to receive and set tc_status
        """
        try:
            print("-> Enter CAN receive loop!")
            while True:
                # Wait until a message is received.
                # print("----> Waiting...")
                message = self.can_bus.recv()

                # print("<---- Received...")
                # print("message length ---> " + str(len(message.data)))
                if len(message.data) > 1:
                    # print("enter if <-------<")
                    #print("ID length: ")
                    #print(message.arbitration_id.bit_length())
                    msb0 = '{0:x} '.format(message.data[0])
                    # print("id----> " + str(int(msb0, 16)))
                    id = int(msb0, 16)

                    msb1 = '{0:x} '.format(message.data[1])
                    # print("value----> " + str(int(msb1, 16)))
                    value = int(msb1, 16)

                    to_temp = int(message.arbitration_id) >> 18
                    to_can = int(to_temp & int('000001111', 2))
                    #print("To can ID: " + str(to_can))

                    s = ''
                    for i in range(message.dlc):
                        s += '{0:x} '.format(message.data[i])
                    #print('CAN receive---->  {}'.format(s))

                    # Lock status
                    if to_can == 1 and id == 35:
                        # Check if it is not the other value
                        # print("Y pos")
                        #self.pos[1] = value
                        self.y_current = value
                        #self.pos_label.configure(text="x: {}  y: {}  z: {}".format(self.pos[0], self.pos[1], self.pos[2]))

        except OSError:
            print('Cannot find PiCAN board')

    def new_img(self):
        folder_path = filedialog.askopenfilename()
        try:
            self.orig_im_cv2 = cv2.imread(folder_path)
            self.orig_im = Image.open(folder_path)
            self.orig_im = self.orig_im.convert('L')
            width, height = self.orig_im.size
            print("Original size: {} x {}".format(width, height))

            basewidth = 430
            wpercent = np.divide(basewidth, width)
            print("wpercent: " + str(wpercent))
            hsize = int(height * wpercent)

            print("basewidth {} hsize {}".format(basewidth, hsize))
            self.im = self.orig_im.resize((basewidth, hsize), Image.ANTIALIAS)

            self.spinnbox_label.configure(
                text="Orig. {}x{} px".format(width, height))
            print("Set new image as label")
            self.tkpi = ImageTk.PhotoImage(self.im)
            self.label.config(image=self.tkpi)

        except:
            self.status_bar.configure(text="No valid image selected!")

    def stripe_img(self):
        print("stripe image")

    def laser(self, state):
        if state is 1:
            print("laser on")
            GPIO.output(self.laser_pin, 0)
        else:
            print("laser off")
            GPIO.output(self.laser_pin, 1)

    def x_move_relative(self, steps=100):
        """Moves to a given target position of the given motor
        """
        _steps = steps * 1

        print("Print straight!")
        address, data = cmd_to_CAN(command="m",
                                   sub_command="mr",
                                   motor_nr=2,
                                   usr_fnct_id=1,
                                   err=0,
                                   data=_steps,
                                   toAddress=2,
                                   fromAddress=1,
                                   respondMessage=1)
        if not PC:
            # Send CAN message
            self.send_CAN(address, data)

        address, data = cmd_to_CAN(command="m",
                                   sub_command="mr",
                                   motor_nr=2,
                                   usr_fnct_id=1,
                                   err=0,
                                   data=_steps,
                                   toAddress=2,
                                   fromAddress=1,
                                   respondMessage=1)
        if not PC:
            # Send CAN message
            self.send_CAN(address, data)

    def x_move_curve(self, steps=100):
        """Moves to a given target position of the given motor
        """
        print("Print curved!")
        address, data = uf_to_CAN(fromAddress=1,
                                  toAddress=2,
                                  respondMessage=1,
                                  usr_fnct_id=1,
                                  command="f",
                                  sub_command="s",
                                  uf_nr=1,
                                  par=2)
        if not PC:
            # Send CAN message
            print("curve")
            #self.send_CAN(address, data)

    def y_move_targetposition(self, pos=700):
        """Moves to a given target position of the given motor
        """
        _steps = pos * 1
        address, data = cmd_to_CAN(command="m",
                                   sub_command="tp",
                                   motor_nr=1,
                                   usr_fnct_id=1,
                                   err=0,
                                   data=_steps,
                                   toAddress=2,
                                   fromAddress=1,
                                   respondMessage=1)
        if not PC:
            # Send CAN message
            self.send_CAN(address, data)

    def home_xy_axis(self):
        """Homes x and y axis and moves back to starting position
        """
        if self.homing == False:
            address, data = uf_to_CAN(fromAddress=1,
                                      toAddress=2,
                                      respondMessage=1,
                                      usr_fnct_id=1,
                                      command="f",
                                      sub_command="s",
                                      uf_nr=1,
                                      par=4)
            if not PC:
                # Send CAN message
                self.send_CAN(address, data)

            self.querry_y_pos()

            self.homing = True
        self.laser(0)

    def querry_y_pos_const(self, par):
        """
        Variables:
        userFunctionVariable1 = 30      158
        userFunctionVariable2 = 31      159
        userFunctionVariable3 = 32      160
        userFunctionVariable4 = 33      161
        userFunctionVariable5 = 34      162
        userFunctionVariable6 = 35      163
        """
        # Start receive task
        # self.tc_receive_CAN_tc_row_task.start()

        # Transform CAN command 163 = ID 35
        # Transform CAN command 158 = ID 30
        while True:
            address, data = uv_from_CAN(fromAddress=1,
                                        toAddress=2,
                                        respondMessage=1,
                                        get_val=163,
                                        command=3,
                                        uf_nr=2,
                                        sub_command=35,
                                        data=0)

            # print("-------> Querry!")
            # Send CAN message
            if not PC:
                # Send CAN message
                self.send_CAN(address, data)

            time.sleep(0.02)

    def querry_y_pos(self):
        """
        Variables:
        userFunctionVariable1 = 30      158
        userFunctionVariable2 = 31      159
        userFunctionVariable3 = 32      160
        userFunctionVariable4 = 33      161
        userFunctionVariable5 = 34      162
        userFunctionVariable6 = 35      163
        """
        # Start receive task
        # self.tc_receive_CAN_tc_row_task.start()

        # Transform CAN command 163 = ID 35
        # Transform CAN command 158 = ID 30
        #while True:
        address, data = uv_from_CAN(fromAddress=1,
                                    toAddress=2,
                                    respondMessage=1,
                                    get_val=163,
                                    command=3,
                                    uf_nr=2,
                                    sub_command=35,
                                    data=0)
        # Send CAN message
        if not PC:
            # Send CAN message
            self.send_CAN(address, data)

        # self.myParent.after(20, self.querry_y_pos)
        #print("Querry!")
        #time.sleep(0.5)

    def send_CAN(self, address, data):
        """Translates command to CAN frame and sends it
        :param message: command to be translated and send over CAN
        """

        # Try to write the message
        try:
            msg = can.Message(arbitration_id=address,
                              data=data,
                              is_extended_id=True)
            # print(msg)

        except AttributeError as error:
            print("error:Create message")
            print(error)
            return

        # Try to send the message
        try:
            self.can_bus.send(msg)
            # print("Message sent on {}".format(self.can_bus.channel_info))
        except can.CanError:
            print("Message could NOT be sent!")

    def serial_connect(self):
        try:
            if self.ser.is_open == False:
                self.ser.port = self.port_name
                self.ser.open()
                if self.ser.is_open == True:
                    #self.connect.configure(text="Disconnect!", foreground="green")
                    self.status_bar.configure(text="CNC found!")
            elif self.ser.is_open == True:
                self.ser.close()
                if self.ser.is_open == False:
                    #self.connect.configure(text="Connect!", foreground="black")
                    self.status_bar.configure(text="Disconnected")
        except:
            self.connect.configure(text="No Device!", foreground="red")

    def move_step(self, axis, step=1):  # int(self.step_spinnbox.get())
        try:
            if self.ser.is_open == True:
                directions = ['x', 'y', 'z', 'c', 's', 'u']
                if directions.index(axis) < 3:
                    self.pos[directions.index(axis)] += step
                if directions.index(axis) >= 3:
                    self.pos[directions.index(axis) - 3] -= step
                self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
                    self.pos[0], self.pos[1], self.pos[2]))
                self.ser.write(b'{}{}\n'.format(step, axis))
            elif self.ser.is_open == False:
                self.status_bar.configure(text="Serial not open!")
        except:
            self.status_bar.configure(text="No Device connected!")

    def set_zero(self):
        for i in range(3):
            self.pos[i] = 0
        self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
            self.pos[0], self.pos[1], self.pos[2]))

    def move_zero(self):
        try:
            if self.ser.is_open == True:
                if self.pos[0] < 0:
                    self.ser.write(b'{}{}\n'.format(self.pos[0] * -1, "x"))
                    self.pos[0] = 0
                    self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
                        self.pos[0], self.pos[1], self.pos[2]))
                elif self.pos[0] > 0:
                    self.ser.write(b'{}{}\n'.format(self.pos[0], "c"))
                    self.pos[0] = 0
                    self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
                        self.pos[0], self.pos[1], self.pos[2]))
                elif self.pos[1] < 0:
                    self.ser.write(b'{}{}\n'.format(self.pos[1] * -1, "y"))
                    self.pos[1] = 0
                    self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
                        self.pos[0], self.pos[1], self.pos[2]))
                elif self.pos[1] > 0:
                    self.ser.write(b'{}{}\n'.format(self.pos[1], "s"))
                    self.pos[1] = 0
                    self.pos_label.configure(text="x: {}  y: {}  z: {}".format(
                        self.pos[0], self.pos[1], self.pos[2]))
            elif self.ser.is_open == False:
                self.status_bar.configure(text="Serial not open!")
        except:
            self.status_bar.configure(text="No Device connected!")

    def rotate_image(
        self
    ):  # rotation behavior not working properly yet, also mirror function introducing: ImageOps.rotate
        try:
            if self.rot_count == 360:
                self.rot_count = 0
            self.im = self.orig_im.rotate(self.rot_count)
            self.rot_count += 90

            width, height = self.im.size
            new_width = int(
                np.divide(width, int(self.pix_per_step_spinnbox.get())))
            new_height = int((new_width * height / width) * self.hight_factor)
            self.im = self.im.resize((new_width, new_height), Image.ANTIALIAS)

            self.tkpi = ImageTk.PhotoImage(self.im)
            self.label.config(image=self.tkpi)
            self.label.config(height=200, width=200)
        except:
            self.status_bar.configure(text="No image defined!")

    # def burn_image(self):
    #     try:
    #         if self.ser.is_open == True and self.pos[0] == 0 and self.pos[1] == 0:
    #             pix = np.array(self.im)
    #             pix = 255 - pix
    #             nrow, ncol = pix.shape
    #
    #             for r in range(nrow):
    #                 if self.pos[0] == 0:
    #                     print ("Forward x")
    #                     for c in range(ncol):
    #                         self.ser.write(
    #                             b'{}a\n'.format(int(np.multiply(pix[r, c], float(self.burn_time_factor.get())))))
    #                         time.sleep(
    #                             np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                         self.move_step("x", int(self.scale_val.get()))
    #                         time.sleep(0.1)
    #                 else:
    #                     print ("Backward x")
    #                     for c in reversed(range(ncol)):
    #                         self.ser.write(
    #                             b'{}a\n'.format(int(np.multiply(pix[r, c], float(self.burn_time_factor.get())))))
    #                         time.sleep(
    #                             np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                         self.move_step("c", int(self.scale_val.get()))
    #                         time.sleep(0.1)
    #
    #                 self.move_step("y", int(self.scale_val.get()))
    #                 time.sleep(0.10)
    #                 print ("x: {}  y: {}  z: {}".format(self.pos[0], self.pos[1], self.pos[2]))
    #
    #             self.move_zero()
    #
    #         elif self.ser.is_open == False:
    #             self.status_bar.configure(text="Serial not open!")
    #     except:
    #         self.status_bar.configure(text="No Device connected!")
    #
    # def burn_image_with_skip(self):
    #     """
    #     Function to switch laser on and off and move through each pixel. White pixel are skipped
    #     """
    #     try:
    #         if self.ser.is_open == True and self.pos[0] == 0 and self.pos[1] == 0:
    #             pix = np.array(self.im)
    #             pix = 255 - pix
    #             nrow, ncol = pix.shape
    #
    #             for r in range(nrow):
    #                 ncol_count_f = 0
    #                 ncol_count_b = 0
    #                 if self.pos[0] == 0:
    #                     print ("Forward x")
    #                     print ("Row: %d" % r)
    #                     for c in range(ncol):
    #                         if pix[r, c] > 0:
    #                             self.move_step("x", int(self.scale_val.get()) * ncol_count_f)
    #                             time.sleep(0.1 * ncol_count_f)
    #                             self.ser.write(b'{}a\n'.format(int(np.multiply(pix[r, c],
    #                                                                            float(self.burn_time_factor.get())))))
    #                             time.sleep(
    #                                 np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                             ncol_count_f = 0
    #                         if c == (ncol - 1):
    #                             self.move_step("x", (ncol_count_f + 1) * int(self.scale_val.get()))
    #                             print ("Return to zero steps forward")
    #                             time.sleep(0.02 * ncol_count_f)
    #                         ncol_count_f += 1
    #
    #                 else:
    #                     print ("Backward x")
    #                     print ("Row: %d" % r)
    #                     for c in reversed(range(ncol)):
    #                         if pix[r, c] > 0:
    #                             self.move_step("c", int(self.scale_val.get()) * ncol_count_b)
    #                             time.sleep(0.1 * ncol_count_b)
    #                             self.ser.write(b'{}a\n'.format(int(np.multiply(pix[r, c],
    #                                                                            float(self.burn_time_factor.get())))))
    #                             time.sleep(
    #                                 np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                             ncol_count_b = 0
    #                         if c == 0:
    #                             self.move_step("c", self.pos[0])
    #                             print ("Return to zero steps backward")
    #                             time.sleep(0.02 * self.pos[0])
    #                         ncol_count_b += 1
    #
    #                 self.move_step("y", int(self.scale_val.get()))
    #                 time.sleep(0.10)
    #                 print ("x: {}  y: {}  z: {}".format(self.pos[0], self.pos[1], self.pos[2]))
    #
    #             self.move_zero()
    #
    #         elif self.ser.is_open == False:
    #             self.status_bar.configure(text="Serial not open!")
    #     except:
    #         self.status_bar.configure(text="No Device connected!")
    #
    #
    # def burn_image_with_skip_jump(self):
    #     """
    #     Function to switch laser on and off and move through each pixel. White pixel are skipped
    #     """
    #     try:
    #         if self.pos[0] == 0 and self.pos[1] == 0:
    #             pix = np.array(self.im)
    #             pix = 255 - pix
    #             nrow, ncol = pix.shape
    #
    #             for c in range(ncol):
    #                 nrow_count_f = 0
    #                 nrow_count_b = 0
    #                 if self.pos[1] == 0:
    #                     print ("Forward y")
    #                     print ("Col: %d" % c)
    #                     for r in range(nrow):
    #                         if pix[r, c] > 0:
    #                             # self.move_step("y", int(self.scale_val.get()) * nrow_count_f)
    #                             #time.sleep(0.1 * nrow_count_f)
    #                             #self.ser.write(b'{}a\n'.format(int(np.multiply(pix[r, c], float(self.burn_time_factor.get())))))
    #                             #time.sleep(np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                             nrow_count_f = 0
    #                         if r == (nrow - 1):
    #                             #self.move_step("y", (nrow_count_f + 1) * int(self.scale_val.get()))
    #                             print ("Return to zero steps forward")
    #                             time.sleep(0.02 * nrow_count_f)
    #                         nrow_count_f += 1
    #
    #                 else:
    #                     print ("Backward y")
    #                     print ("Col: %d" % c)
    #                     for r in reversed(range(nrow)):
    #                         if pix[r, c] > 0:
    #                             self.move_step("s", int(self.scale_val.get()) * nrow_count_b)
    #                             time.sleep(0.1 * nrow_count_b)
    #                             self.ser.write(b'{}a\n'.format(int(np.multiply(pix[r, c],
    #                                                                            float(self.burn_time_factor.get())))))
    #                             time.sleep(
    #                                 np.divide(np.multiply(pix[r, c], float(self.burn_time_factor.get())), 1000) + 0.15)
    #                             nrow_count_b = 0
    #                         if r == 0:
    #                             self.move_step("s", self.pos[1])
    #                             print ("Return to zero steps backward")
    #                             time.sleep(0.02 * self.pos[1])
    #                         nrow_count_b += 1
    #
    #                 self.move_step("x", int(self.scale_val.get()))
    #                 time.sleep(0.10)
    #                 print ("x: {}  y: {}  z: {}".format(self.pos[0], self.pos[1], self.pos[2]))
    #
    #             self.move_zero()
    #
    #         elif self.ser.is_open == False:
    #             self.status_bar.configure(text="Serial not open!")
    #     except:
    #         self.status_bar.configure(text="No Device connected!")

    def image_resize(self,
                     image,
                     width=None,
                     height=None,
                     inter=cv2.INTER_AREA):
        # initialize the dimensions of the image to be resized and
        # grab the image size
        dim = None
        (h, w) = image.shape[:2]

        # if both the width and height are None, then return the
        # original image
        if width is None and height is None:
            return image

        # check to see if the width is None
        if width is None:
            # calculate the ratio of the height and construct the
            # dimensions
            r = height / float(h)
            dim = (int(w * r), height)

        # otherwise, the height is None
        else:
            # calculate the ratio of the width and construct the
            # dimensions
            r = width / float(w)
            dim = (width, int(h * r))

        # resize the image
        resized = cv2.resize(image, dim, interpolation=inter)

        # return the resized image
        return resized

    def wait_to_finish(self):
        self.y_current = 1
        while self.y_current != 0:
            # self.querry_y_pos()
            print("y current 1: " + str(self.y_current))
            time.sleep(0.2)

    def blink_LED(self, par):
        while True:
            if self.run == True:
                self.led.set_orange_green_mix()
                time.sleep(0.5)
                self.led.set_orange_green_mix2()
                time.sleep(0.5)

    def draw_img_new(self, par):

        if self.homing == True:

            print("Start printing ...")
            self.run = True
            if not PC:
                self.blink_led_task.start()

            wait_for_pen = 1.4

            or_nrow, or_ncol = self.orig_im_cv2.shape[:2]
            print("Original Nraws {} Original Ncols {}".format(
                or_nrow, or_ncol))

            print("Curved: " + str(self.var1.get()))
            # Get desired image height
            image_height = int(self.variable.get())

            print("image_height: " + str(image_height))
            scale_factor = np.divide(or_nrow, image_height)
            print("scale factor: " + str(scale_factor))
            image_width = int(np.divide(or_ncol, scale_factor))
            image_width = int(np.divide(image_width, 7))

            print("Image height set to: " + str(image_height) +
                  " image width set to: " + str(image_width))

            # image_height = 700
            invert = False  # draw black or white

            # self.orig_im_cv2 = self.image_resize(self.orig_im_cv2, height = image_height)

            self.orig_im_cv2 = cv2.resize(self.orig_im_cv2,
                                          (image_width, image_height))

            self.orig_im_cv2 = cv2.cvtColor(self.orig_im_cv2,
                                            cv2.COLOR_BGR2GRAY)
            __, self.orig_im_cv2 = cv2.threshold(
                self.orig_im_cv2, 128, 255,
                cv2.THRESH_BINARY + cv2.THRESH_OTSU)

            nrow, ncol = self.orig_im_cv2.shape[:2]
            c = ncol - 1
            r = nrow
            print("Nraws {} Ncols {}".format(r, c))

            if invert:
                self.orig_im_cv2 = (255 - self.orig_im_cv2)

            # print(self.orig_im_cv2)
            # cv2.imshow("im", self.orig_im_cv2)
            # cv2.waitKey()

            img = self.orig_im_cv2
            positive = True
            prev_pix = 255

            for c in range(ncol - 1, -1, -1):
                print("c: " + str(c))
                if sum(img[:, c]) == ncol * 255:
                    print("Empty line -- skip to next line!")
                    print("----")
                    prev_pix = 255

                else:
                    if positive:
                        print("Positive!")

                        for idx, pix in enumerate(reversed(img[:, c])):
                            # print(idx, pix)

                            # ----------------Plotting--------------------
                            if pix == prev_pix:
                                pass
                                # print("same color!")
                            elif pix < prev_pix:
                                # draw color is black
                                print((len(img[:, c]) - idx), pix)
                                print(
                                    "Laser off - move to idx: {}!".format(idx))
                                if not PC:
                                    self.laser(0)
                                    # time.sleep(wait_for_pen)
                                    self.wait_to_finish()

                                    self.y_move_targetposition(idx)

                                    self.wait_to_finish()

                                    # time.sleep(wait_for_pen)

                            elif pix > prev_pix:
                                # draw color is white
                                print((len(img[:, c]) - idx), pix)
                                print(
                                    "Laser on - move to idx: {}!".format(idx))
                                if not PC:
                                    self.laser(1)
                                    # time.sleep(wait_for_pen)
                                    self.wait_to_finish()

                                    self.y_move_targetposition(idx)

                                    self.wait_to_finish()

                                    # time.sleep(wait_for_pen)

                            if idx == len(img[:, c]) - 1:
                                # move to the end
                                print(
                                    "Move to the end to idx: {}!".format(idx))
                                print((len(img[:, c]) - idx), pix)
                                if pix > 0:
                                    # draw color is black
                                    print(
                                        "Laser off - move to idx: {}!".format(
                                            idx))
                                    if not PC:
                                        self.laser(0)
                                        # time.sleep(wait_for_pen)
                                        self.wait_to_finish()

                                        # self.y_move_targetposition(idx)

                                        # self.wait_to_finish()

                                elif pix == 0:
                                    # draw color is white
                                    print("Laser on - move to idx: {}!".format(
                                        idx))
                                    if not PC:
                                        self.laser(1)
                                        # time.sleep(wait_for_pen)
                                        self.wait_to_finish()

                                        self.y_move_targetposition(idx)

                                        self.wait_to_finish()

                                        # time.sleep(wait_for_pen)

                            prev_pix = pix
                            # ------------------------------------------

                        print("----")
                        positive = False
                        prev_pix = 255

                    else:
                        print("Negative!")

                        for idx, pix in enumerate(img[:, c]):
                            # print(idx, pix)

                            # ----------------Plotting--------------------
                            if pix == prev_pix:
                                pass
                                # print("same color!")
                            elif pix < prev_pix:
                                # draw color is black
                                print((len(img[:, c]) - idx), pix)
                                print("Laser off - move to idx: {}!".format(
                                    (len(img[:, c]) - idx)))
                                if not PC:
                                    self.laser(0)
                                    # time.sleep(wait_for_pen)
                                    self.wait_to_finish()

                                    self.y_move_targetposition(
                                        (len(img[:, c]) - idx))

                                    self.wait_to_finish()

                                    # time.sleep(wait_for_pen)

                            elif pix > prev_pix:
                                # draw color is white
                                print((len(img[:, c]) - idx), pix)
                                print("Laser on - move to idx: {}!".format(
                                    (len(img[:, c]) - idx)))
                                if not PC:
                                    self.laser(1)
                                    # time.sleep(wait_for_pen)
                                    self.wait_to_finish()

                                    self.y_move_targetposition(
                                        (len(img[:, c]) - idx))

                                    self.wait_to_finish()

                                    # time.sleep(wait_for_pen)

                            if idx == len(img[:, c]) - 1:
                                # move to the end
                                print((len(img[:, c]) - idx), pix)
                                print("Move to the end to idx: {}!".format(
                                    (len(img[:, c]) - idx)))
                                if pix > 0:
                                    # draw color is black
                                    print(
                                        "Laser off - move to idx: {}!".format(
                                            (len(img[:, c]) - idx)))
                                    if not PC:
                                        self.laser(0)
                                        # time.sleep(wait_for_pen)
                                        self.wait_to_finish()

                                        # self.y_move_targetposition(0)

                                        # self.wait_to_finish()

                                elif pix == 0:
                                    # draw color is white
                                    print("Laser on - move to idx: {}!".format(
                                        (len(img[:, c]) - idx)))
                                    if not PC:
                                        self.laser(1)
                                        # time.sleep(wait_for_pen)
                                        self.wait_to_finish()

                                        self.y_move_targetposition(0)

                                        self.wait_to_finish()

                                        # time.sleep(wait_for_pen)

                            prev_pix = pix
                            # ------------------------------------------

                        print("----")
                        positive = True
                        prev_pix = 255

                # X MOVE with wheels
                print("Move to next line!")
                print("Laser off!")
                self.laser(0)
                print("----> x ")
                # time.sleep(wait_for_pen)

                self.wait_to_finish()

                if not self.var1.get():
                    print("Straight print!")
                    self.x_move_relative(steps=6)
                    time.sleep(0.2)
                else:
                    print("Curve print!")
                    self.x_move_curve()
                    time.sleep(0.4)

            # Done
            # self.pos_label.configure(text="Done printing!")
            self.run = False
            time.sleep(0.5)
            self.led.set_blue()

            self.homing = False
class PageOptions():
    def __init__(self):
        self.root = Tk()
        self.createWidgets()
        self.root.mainloop()

    def initialize_variables(self):
        # Initial size of the app
        self.HEIGHT = 600
        self.WIDTH = 800
        self.root.title("Categorization Dialog Widget")
        self.root.minsize(750, 550)

    def createWidgets(self):
        self.initialize_variables()

        # Background
        self.canvas = Canvas(self.root, height=self.HEIGHT, width=self.WIDTH)
        self.background_label = Label(self.root, bg='#3C1E5F')
        self.background_label.place(relwidth=1, relheight=1)
        self.canvas.pack()

        # Upper frame with logo and info message
        self.higher_frame = Frame(self.root, bg='#FFD164', bd=5)
        self.higher_frame.place(relx=0.5, rely=0.1, relwidth=0.85, relheight=0.35, anchor='n')
        self.logo = Canvas(self.higher_frame, bd=1)
        self.logo.place(relx=0, rely=0, relwidth=1, relheight=0.5)
        self.img = PhotoImage(file="logo.png")
        self.img = self.img.subsample(6)
        self.logo.create_image(0, 0, anchor='nw', image=self.img)
        self.var = "Sentiment Classification and Categorization of txt files"
        self.infoMessage = Message(self.higher_frame, text=self.var, justify='center', width=350, font=("Courier bold", 16))
        self.infoMessage.place(relx=0.4, rely=0.05, relwidth=0.5, relheight=0.3)

        # Menubar with Option, Result and Direct input
        self.menubar()

        # Lower frame with scrollbars for displaying of categories and file names
        self.lower_frame = Frame(self.root, bg='#FFD164', bd=5)
        self.lower_frame.place(relx=0.5, rely=0.35, relwidth=0.85, relheight=0.55, anchor='n')
        self.lower_frame.grid_rowconfigure(0, weight=1)
        self.lower_frame.grid_columnconfigure(0, weight=1)
        self.optionCanvas = Canvas(self.lower_frame, bg='white', bd=3)
        self.optionCanvas.place(relwidth=1, relheight=1)
        # select language (English or Swedish)
        self.selectLanguage(self.optionCanvas)
        # open folder with input files
        self.openFolder = Label(self.optionCanvas, text="Open a folder with input files", justify='left',
                                bg='white',
                                font=("Courier bold", 12))
        self.openFolder.place(relx=0.1, rely=0.4, relwidth=0.3, relheight=0.2)
        self.button = Button(self.optionCanvas, text="Browse", font=("Courier", 12), bg='#EE7C7D',
                             activebackground='#f2d9e6',
                             command=lambda: self.fileDialog())
        self.button.place(relx=0.5, rely=0.4, relwidth=0.3, relheight=0.15)
        # save result in excel file
        self.CheckVar = IntVar()
        self.excelFileCheckbutton = Checkbutton(self.optionCanvas, text="Save as excel", variable=self.CheckVar, \
                         onvalue=1, offvalue=0, bg='white', font=("Courier bold", 12), height=5, width=20)
        self.excelFileCheckbutton.place(relx=0.1, rely=0.6, relwidth=0.3, relheight=0.15)

    # Middle frame with buttons bar
    def menubar(self):
        self.middle_frame = Frame(self.root, bg='#FFD164', bd=5)
        self.middle_frame.place(relx=0.5, rely=0.25, relwidth=0.85, relheight=0.1, anchor='n')
        self.button = Button(self.middle_frame, text="Options", font=("Courier", 12), bg='#EE7C7D',
                             activebackground='#f2d9e6',
                             command=lambda: self.fileDialog())
        self.button.place(relx=0.1, relwidth=0.2, relheight=1)
        self.button = Button(self.middle_frame, text="Result", font=("Courier", 12), bg='#EE7C7D',
                             activebackground='#f2d9e6',
                             command=lambda: self.fileDialog())
        self.button.place(relx=0.4, relwidth=0.2, relheight=1)
        self.button = Button(self.middle_frame, text="Direct input", font=("Courier", 12), bg='#EE7C7D',
                             activebackground='#f2d9e6',
                             command=lambda: self.fileDialog())
        self.button.place(relx=0.7, relwidth=0.2, relheight=1)

    # select language (English or Swedish)
    def selectLanguage(self, parentWidget):
        # Create a Tkinter variable
        self.tkvar = StringVar()
        # Dictionary with options
        self.choices = {'English', 'Swedish'}
        self.tkvar.set('English')  # set the default option
        # Popup menu with languages
        self.popupMenu = OptionMenu(parentWidget, self.tkvar, *self.choices)
        self.popupLabel = Label(parentWidget, text="Choose a language", bg='white', justify='left',
                                font=("Courier bold", 12))
        self.popupLabel.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.2)
        self.popupMenu.configure(bd=3, bg='#EE7C7D')
        self.popupMenu.place(relx=0.5, rely=0.1, relwidth=0.3, relheight=0.15)
        # on change dropdown value
        def change_dropdown(*args):
            print(self.tkvar.get())
        # link function to change dropdown
        self.tkvar.trace('w', change_dropdown)

    # Gets the selected folder by the user and uses keywordSearch in txt files, then presents categories and file names
    def fileDialog(self):
        try:
            self.folderSelected = filedialog.askdirectory()
            self.categorizer = Categorizer(self.folderSelected)
            self.dict_obj = self.categorizer.categorizeFilesFromDirectoryInMapAndSubDirectory()
            self.results.insert(END, "Category".ljust(20, ' ') + "File name")
            self.results.insert(END, "\n")
            for key, val in self.dict_obj.items():
                self.results.insert(END, str(key).ljust(20, ' ') + str(val))
        except UnicodeDecodeError:
            self.results.insert(END, "Selected folder does not contain txt files.")
示例#15
0
var_algo = StringVar(Frame1)
var_algo.set("All")  # initial value

with open(
        r'C:\Users\Mudraksh_Server1\Desktop\sparedux\squareoffUI\strategylist.txt'
) as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    Algo_Name = []
    for row in csv_reader:
        # print(row)
        if row:
            Algo_Name.append(row[0])

textclient = OptionMenu(Frame1, var_algo, *Algo_Name)
textclient.place(relx=0.3, rely=0.108, height=24, width=150)

Label2 = tk.Label(Frame1)
Label2.place(relx=0.082, rely=0.275, height=25, width=85)
Label2.configure(background="#d9d9d9")
Label2.configure(disabledforeground="#a3a3a3")
Label2.configure(font=font12)
Label2.configure(foreground="#000000")
Label2.configure(text='''Enter OTP: ''')

input_var = StringVar()
input_entyBox = ttk.Entry(win, width=16, textvariable=input_var)
input_entyBox.place(relx=0.32, rely=0.300, height=24, width=150)


def action():
示例#16
0
                   font=32).place(x=250, y=250)
husb_label = Label(root,
                   text="Animal Husbandary",
                   bg="#1D2745",
                   fg="white",
                   font=32).place(x=750, y=250)
choices0 = {'Wheat', 'Rice', 'Cotton', 'Tea', 'Coffee', 'Maize', 'Sugarcane'}
tkvar0 = StringVar(root)
tkvar0.set('Select')
popupMenu0 = OptionMenu(root, tkvar0, *choices0)
crops_label = Label(root,
                    text="Choose Your Crop",
                    bg="#1D2745",
                    fg="white",
                    font=32).place(x=150, y=300)
popupMenu0.place(x=350, y=300)
land_label = Label(root,
                   text="Enter Your Land Size(in Acres)",
                   bg="#1D2745",
                   fg="white",
                   font=32).place(x=150, y=350)
Land_1 = Entry(root)
Land_1.place(x=350, y=350)
choices3 = {'Coastal', 'Mountains', 'Plateau'}
tkvar3 = StringVar(root)
tkvar3.set('Select')
popupMenu3 = OptionMenu(root, tkvar3, *choices3)
crops_label = Label(root,
                    text="Choose Your Region",
                    bg="#1D2745",
                    fg="white",
示例#17
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        # styles
        leftPadding = 20
        backgroundColor = '#3E4149'
        canvasSize = "300x350"

        # Canvas Size
        parent.geometry(canvasSize)
        self.configure(bg='#3E4149')
        parent.title("WMA File Converter - Nick Taras") 

        # Submit Button
        def convertFilesHandler():
            convertFile(fromDirectory.get(), selectedFileType.get())

        # Convert File Util
        # print ("Converting files from: ", _path + ' to ' + _type + " 's.")
        def convertFile(_path, _type):
            for i in Path(_path).glob('**/*'):
                if str(i).endswith('.wma'):
                    outputChildProcess = subprocess.check_output(['ftransc', '-q', 'extreme', '-f', _type, str(i)])
                    if str(outputChildProcess).find("Success") != -1:
                        progressOutputVar.set("File Success: " + str(i))
                        progressOutput.configure(bg = "#105b10")
                        filesConvertedOutputVar.set(filesConvertedOutputVar.get()+1)
                        self.update()
                    else:
                        progressOutputVar.set("File Skipped: " + str(i))
                        progressOutput.configure(bg = "#992a2a")
                        self.update()

        # Open url to GitHub
        def openUrlHandler():
            webbrowser.open("https://github.com/nicktaras/audio_converter")
            
        # Directory
        fromDirectory = StringVar()
        fromDirectory.set('')

        # Supported File types:
        supportedFileTypes = ['mp3', 'ogg']
        selectedFileType = StringVar(self)
        selectedFileType.set(supportedFileTypes[0])

        # Browse File
        # print(fromDirectory.get())
        def fromDirectoryHandler():
            fromDirectory.set(fd.askdirectory())
            directoryTitleVar.set((fromDirectory.get()[:255] + '...') if len(fromDirectory.get()) > 255 else fromDirectory.get())
            self.update_idletasks()

        # import gui           

        w = OptionMenu(self, selectedFileType, *supportedFileTypes)
        w.pack()
        w.place(x = leftPadding, y = 250)
        w.config(bg = "#3E4149")

        # labels

        appTitle = Label(self, text="Windows Media Audio Converter", background="#3E4149", foreground="white",  font="none 14 bold")
        appTitle.pack()
        appTitle.place(x = leftPadding, y = 14)

        appFooter = Label(self, anchor="center", height=2, text="by Nick Taras    |                       ", width=37, background="orange red", foreground="white", borderwidth=2, relief="groove")
        appFooter.pack()
        appFooter.place(x = 0, y = 316)

        progressOutputVar = StringVar()
        progressOutputVar.set('')
        progressOutput = Label(self, wraplength=250, width=32, textvariable=progressOutputVar, foreground="white", justify="left")
        progressOutput.configure(bg = "#234")
        progressOutput.pack()
        progressOutput.place(x = leftPadding, y = 160)

        filesConvertedLabel = Label(self, wraplength=250, text="Files Successfully Converted:", foreground="white", justify="left")
        filesConvertedLabel.configure(bg = backgroundColor)
        filesConvertedLabel.pack()
        filesConvertedLabel.place(x = leftPadding, y = 208)

        filesConvertedOutputVar = IntVar()
        filesConvertedOutputVar.set(0)
        filesConvertedOutput = Label(self, wraplength=250, textvariable=filesConvertedOutputVar, foreground="white", justify="left")
        filesConvertedOutput.configure(bg = backgroundColor)
        filesConvertedOutput.pack()
        filesConvertedOutput.place(x = 210, y = 208)

        directoryTitleVar = StringVar()
        directoryTitleVar.set('')
        directoryTitle = Label(self, wraplength=250, textvariable=directoryTitleVar, background=backgroundColor, foreground="white", justify="left")
        directoryTitle.pack()
        directoryTitle.place(x = leftPadding, y = 90)

        # buttons
        convertBtn = guiFactory.createButton(self, Button, "Convert", convertFilesHandler, "#3E4149", "center", 200, 250)
        linkBtn = guiFactory.createButton(self, Button, "Github", openUrlHandler, "orange red", "center", 175, 320)
        fromDirectoryBtn = guiFactory.createButton(self, Button, "Choose Music Directory", fromDirectoryHandler, "#3E4149", "center", leftPadding, 50)
示例#18
0
        conn.commit()
        conn.close()
    except Exception as e:
        print(e)


Label(win, text="Registration form", width=20, font=("bold", 20)).place(x=70,
                                                                        y=53)
Label(win, text="FullName", width=20, font=("bold", 10)).place(x=70, y=130)
Entry(win, textvar=fname).place(x=240, y=130)
Label(win, text="Email", width=20, font=("bold", 10)).place(x=70, y=180)
Entry(win, textvar=email).place(x=240, y=180)
Label(win, text="Gender", width=20, font=("bold", 10)).place(x=70, y=230)
Radiobutton(win, text="Male", padx=5, variable=gender, value='M').place(x=240,
                                                                        y=230)
Radiobutton(win, text="Female", padx=20, variable=gender,
            value='F').place(x=310, y=230)
Label(win, text="country", width=20, font=("bold", 10)).place(x=70, y=280)
list1 = ['Canada', 'India', 'UK', 'Nepal', 'Iceland', 'South Africa']
droplist = OptionMenu(win, country, *list1)
droplist.config(width=15)
country.set('select your country')
droplist.place(x=240, y=280)
Label(win, text="Programming", width=20, font=("bold", 10)).place(x=70, y=330)
Checkbutton(win, text="java", variable=java).place(x=240, y=330)
Checkbutton(win, text="python", variable=python).place(x=310, y=330)
Button(win, text='Submit', width=15, bg='brown', fg='white',
       command=database).place(x=70, y=380)
Button(win, text='View All', width=15, bg='brown', fg='white',
       command=view).place(x=230, y=380)
win.mainloop()
示例#19
0
def MP3PLAYING():  #Main interface which initiates the MP3 player
    global seek
    global oc2
    global listofsongs
    global listofsongs2
    global songlist
    global songname 
    global len1
    global time1
    songname=Label(root5,textvariable=m,width=90,bg="#220047",fg="#CE9141",font=("roboto",13))
    songname.place(x=-120,y=450)
        
    pygame.mixer.init()
    songlist=Listbox(root5,selectbackground="#CE9141",height=14,width=60,relief=GROOVE,bd=3,bg="#220047",fg="#CE9141",font=("fixedsys",10))
    songlist.place(x=20,y=205)
  
    a=StringVar()
    a.set("Default")
    
    oc=StringVar(root5)
    oc.set("Select")
    
    
    listofsongs2.reverse()
    for h in listofsongs2:
        songlist.insert(0,h)
    listofsongs2.reverse()
    
    #currentsong=Label(root5,text="Current Song:",font=("georgia",15),bg="#220047",fg="#CE9141")
    #currentsong.place(x=230,y=500)
    
    orderofsongs=Label(root5,text="Your Playlist",font=("georgia",15),bg="#220047",fg="#CE9141")
    orderofsongs.place(x=40,y=170)
    
    startbutton=Button(root5,text="Start",bg="#CE9141",relief=RAISED,fg="#220047",bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    startbutton.place(x=400,y=480)
    
    playnext=Button(root5,text=">>>",bg="#CE9141",relief=RAISED,fg="#220047",bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    playnext.place(x=355,y=480)
    
    
    playbefore=Button(root5,text="<<<",bg="#CE9141",fg="#220047",relief=RAISED,bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    playbefore.place(x=190,y=480)
    
    stop=Button(root5,text="Stop",bg="#CE9141",fg="#220047",relief=RAISED,bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    stop.place(x=137,y=480)
    
    pause=Button(root5,text="Pause",bg="#CE9141",fg="#220047",relief=RAISED,bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    pause.place(x=237,y=480)
     
    play=Button(root5,text="Play",bg="#CE9141",fg="#220047",relief=RAISED,bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
    play.place(x=300,y=480)

    volume1=Label(root5,text="Volume",font=("georgia",11),fg="#CE9141",bg="#220047")
    volume1.place(x=533,y=190)
    
    selection=MP3(listofsongs[0])
    len1=selection.info.length
    len1//=1
 
    seek=Scale(root5,from_=0,to=len1,orient=HORIZONTAL,length=400,cursor="cross",bd=1,bg="#CE9141",fg="#220047",activebackground="#220047",command=seek1)
    seek.place(x=100,y=530)
    
    oc1=StringVar(root5)
    oc1.set("Welcome"+ " "+ user11)
    
    options=["Home","Back","Close"]
    dropdown=OptionMenu(root5,oc1,*options,command=choice1)
    dropdown.configure(font=("georgia",15),fg="#220047",bg="#CE9141",activebackground="#CE9141",activeforeground="#220047")
    dropdown.place(x=200,y=110)
    
    oc2=StringVar(root5)
    oc2.set("Options")
    
    options1=["Shuffle[]","Random[?]","Delete[-]","Add[+]"]
    dropdown1=OptionMenu(root5,oc2,*options1,command=choice2)
    dropdown1.configure(text="Options",font=("georgia",10),fg="#220047",bg="#CE9141",activebackground="#220047",activeforeground="#CE9141")
    dropdown1.place(x=500,y=50)
    
    volume2=Scale(root5,from_=100,to=0,orient=VERTICAL,length=210,cursor="cross",bd=1,bg="#CE9141",fg="#220047",activebackground="#220047",command=volume)
    volume2.set(100)
    volume2.place(x=540,y=215)
    pygame.mixer.music.set_volume(100)
    
    if conditionalval==2:
        saveplaylist=Button(root5,text="Save",bg="#CE9141",fg="#220047",relief=RAISED,bd=1,activebackground="#220047",activeforeground="#CE9141",font=("fixedsys",10))
        saveplaylist.place(x=40,y=560)
        saveplaylist.bind("<Button>",createplay)
    elif conditionalval==3:
        orderofsongs.place_forget()
        defer="Your Playlist :"+" "+appendlist
        orderofsongs=Label(root5,text=defer,font=("georgia",15),bg="#220047",fg="#CE9141")
        orderofsongs.place(x=40,y=170)
        
    else:
        print("okay")

    
    """time1=IntVar()
    time1.set(0)

    timer1= Label(root5, textvar= time1,font=("georgia",8),fg="#220047",bg="#CE9141")
    timer1.place(x= 250, y= 550)"""
    
    pause.bind("<Button-1>",pausesong)
    play.bind("<Button-1>",unpause)
    startbutton.bind("<Button-1>",playmusic)
    playnext.bind("<Button-1>",nextsong)
    playbefore.bind("<Button-1>",previous)
    stop.bind("<Button-1>",stopmusic)

    pygame.mixer.music.load(listofsongs[0])
    pygame.mixer.music.play()


    updatename()
    """timer()
示例#20
0
    def __init__(self, master):
        '''
        Saves basic GUI buttons and data entries
        '''

        self.master = master
        master.geometry("600x500")
        master.title("Enrichment Analysis Tool")

        # string variables from user input
        self.fsp = StringVar() # Formulation Sheet file Path
        self.ncp = StringVar() # Normalized Counts file Path
        self.sc = StringVar()  # list of Sorted Cells
        self.dfp = StringVar() # Destination Folder Path
        self.tbp = StringVar() # Top/Bottom Percent
        self.op = StringVar()  # Outliers Percentile
        self.opt = StringVar() # Average and sort by
        self.org = StringVar() # Organ
        self.ct = StringVar()  # Cell Type

        Label(master, text="Enrichment Analysis", relief="solid", font=("arial", 16,\
            "bold")).pack()

        Label(master, text="Formulation Sheet File Path", font=("arial", 12,\
            "bold")).place(x=20, y=50)
        Button(master, text="Formulation sheet file", width=20, fg="green", font=("arial",\
            16), command=self.open_excel_file).place(x=370, y=48)

        Label(master, text="Normalized Counts CSV File Path", font=("arial", 12,\
            "bold")).place(x=20, y=82)
        Button(master, text="Normalized counts file", width=20, fg="green", font=("arial",\
            16), command=self.open_csv_file).place(x=370, y=80)

        Label(master, text="List of Sorted Cells (separate by commas)", font=("arial", 12,\
            "bold")).place(x=20, y=114)
        Entry(master, textvariable=self.sc).place(x=370, y=112)

        Label(master, text="Destination Folder Path", font=("arial", 12, "bold")).place(\
            x=20, y=146)
        Entry(master, textvariable=self.dfp).place(x=370, y=144)

        Label(master, text="Top/Bottom Percent", font=("arial", 12, "bold")).place(x=20,\
            y=178)
        Entry(master, textvariable=self.tbp).place(x=370, y=176)

        Label(master, text="(OPTIONAL: Default = 99.9) Outliers Percentile", font=("arial",\
            12, "bold")).place(x=20, y=212)
        Entry(master, textvariable=self.op).place(x=370, y=210)

        # Pick how user would like data sorted by
        Label(master, text="Sort by", font=("arial", 12, "bold")).place(x=20,\
            y=244)
        options = ["Organ average","Cell type average", "Average of all samples"]

        org_droplist = OptionMenu(master, self.opt, *options)
        self.opt.set("Sorting method")
        org_droplist.config(width=15)
        org_droplist.place(x=370, y=246)

        Label(master, text="Select organ and/or cell type", font=("arial", 12, "bold")).place(x=20,\
            y=276)

        # drop down menu
        organ = ["Liver", "Lung", "Spleen", "Heart", "Kidney", "Pancreas", "Marrow", "Muscle",\
        "Brain", "Lymph Node", "Thymus"]
        cell_type = ["Hepatocytes", "Endothelial", "Kupffer", "Other Immune", "Dendritic",\
        "B cells", "T cells", "Macrophages", "Epithelial", "Hematopoetic Stem Cells",\
        "Fibroblasts", "Satellite Cells", "Other"]

        org_droplist = OptionMenu(master, self.org, *organ)
        self.org.set("Select Organ")
        org_droplist.config(width=15)
        org_droplist.place(x=220, y=278)

        ct_droplist = OptionMenu(master, self.ct, *cell_type)
        self.ct.set("Select Cell Type")
        ct_droplist.config(width=15)
        ct_droplist.place(x=400, y=278)

        Button(master, text="ENTER", width=16, fg="blue", font=("arial", 16),\
            command=self.enrichment_analysis).place(x=150, y=310)
        Button(master, text="CANCEL", width=16, fg="blue", font=("arial", 16),\
            command=exit1).place(x=300, y=310)
    def __init__(self, parent, controller):
        #__init__
        #Create the Window and find the windows
        tk.Frame.__init__(self, parent)
        self.find_comports()

        #Top Menu
        #Set the Theme Variables
        topmenu_textcolor = 'white'  #The text color for all the widgets on the canvas
        topmenu_bgcolor = '#383a39'  #The background color for all the widgets on the canvas

        #Create the Canvas
        global top_menu
        top_menu = tk.Canvas(self, height=140, width=1400, bg=topmenu_bgcolor)
        top_menu.grid(
            row=0,
            column=0,
        )

        #Program Title
        program_title = Label(top_menu,
                              text="R4LA LED Configurator",
                              font=("Helvetica", 18, "bold", "italic"),
                              fg=topmenu_textcolor,
                              bg=topmenu_bgcolor)
        program_title.place(relx=0.2, rely=0.5, anchor=CENTER)

        #Configure Button
        Configure_Button = Button(top_menu,
                                  height=5,
                                  width=12,
                                  text='Configure',
                                  command=self.Configure_FUNC)
        Configure_Button.place(relx=0.9, rely=0.17)

        #COM Port Drop Down Menu
        COM_Port_Dropdown_Menu = OptionMenu(
            top_menu,
            COMport_start_text,
            *COMport_results,
        )
        COM_Port_Dropdown_Menu.place(relx=0.81, rely=0.17, anchor=NW)

        #Side Menu (Presets Need improvement)
        #Set the Theme Variables
        _sidemenu_textcolor = 'white'  #The text color for all the widgets on the canvas
        sidemenu_bgcolor = '#2e2e2e'  #The background color for all the widgets on the canvas

        #Create the Canvas
        side_menu = tk.Canvas(self,
                              height=671,
                              width=200,
                              bd=0,
                              bg=sidemenu_bgcolor)
        side_menu.place(x=0, y=142, anchor=NW)

        #Content Window
        #Create the Main Canvas
        global Content_Window_Canvas
        Content_Window_Canvas = tk.Canvas(self,
                                          height=671,
                                          width=1194,
                                          bg='grey')
        Content_Window_Canvas.place(x=202, y=142, anchor=NW)

        #Create the Options Sub-Canvas
        options_canvas = Canvas(Content_Window_Canvas,
                                bg='grey',
                                highlightthickness=0)
        options_canvas.place(x=2, y=2, anchor=NW)

        #Create the LED Sub-Canvas
        global LED_Canvas
        LED_Canvas = Canvas(Content_Window_Canvas,
                            bg='grey',
                            highlightthickness=0)
        LED_Canvas.place(relx=0.5, rely=0.5, anchor=CENTER)

        #Clear all LEDs Button
        Clear_LED_Colors_BTN = Button(options_canvas,
                                      text="Clear LEDs",
                                      width=12,
                                      command=self.Clear_LED_Colors_FUNC)
        Clear_LED_Colors_BTN.grid(row=1, column=1)

        #Fill all LEDs Button
        fill_colors_btn = Button(options_canvas,
                                 text='Fill LEDs',
                                 width=12,
                                 command=self.Fill_Colors_FUNC)
        fill_colors_btn.grid(row=1, column=2)

        #Color Chooser
        color_chooser = Button(options_canvas,
                               text="Select Color",
                               command=self.openColorDialog)
        color_chooser.grid(row=2, column=1)

        #Color Preview
        global color_preview
        color_preview = Label(options_canvas, width=2, text="", bg='black')
        color_preview.grid(row=2, column=2)

        #Bottom LED Section Label
        B_LED_Label = Label(LED_Canvas,
                            text="Bottom LEDs",
                            font='Calibri'
                            '24',
                            bg='grey',
                            fg='white')
        B_LED_Label.grid(row=0, column=0, columnspan=46)

        #Bottom LED Section Spacer
        Bottom_LED_Space = Label(LED_Canvas, bg='grey', width=3)
        Bottom_LED_Space.grid(row=4, column=0, columnspan=46)

        #Center Spacer
        Center_Space = Label(LED_Canvas, bg='grey', width=3)
        Center_Space.grid(row=0, column=23, rowspan=12)

        #Top LED Section Label
        T_LED_Label = Label(LED_Canvas,
                            text="Top LEDs",
                            font='Calibri'
                            '24',
                            bg='grey',
                            fg='white')
        T_LED_Label.grid(row=8, column=0, columnspan=46)

        #Top LED Section Spacer
        Top_LED_Space = Label(LED_Canvas, bg='grey', width=3)
        Top_LED_Space.grid(row=12, column=0, columnspan=46)

        #LED Variables
        global NUMLEDs
        NUMLEDs = 443

        #Generate the Dictionary
        global set_color
        set_color = {}
        for i in range(NUMLEDs + 1):
            set_color['led{}'.format(i)] = '0x000000'

    #Create the LEDs
        global LED_List
        LED_List = []

        for i in range(NUMLEDs + 1):
            LED_List.append('led' + str(i))

        for i in range(NUMLEDs + 1):
            globals()[LED_List[i]] = Button(LED_Canvas,
                                            height=1,
                                            width=2,
                                            text='led{}'.format(i),
                                            fg='black',
                                            bg='black')
            globals()[LED_List[i]].bind("<Button-1>",
                                        self.Change_LED_Color_FUNC)

    #Place the LEDs on the Canvas:
    #BS1 Widget Cluster
        globals()[LED_List[60]].grid(row=5, column=22)
        globals()[LED_List[61]].grid(row=6, column=21)
        globals()[LED_List[62]].grid(row=5, column=21)
        globals()[LED_List[63]].grid(row=5, column=20)
        globals()[LED_List[64]].grid(row=6, column=20)
        globals()[LED_List[65]].grid(row=7, column=20)
        globals()[LED_List[66]].grid(row=7, column=19)
        globals()[LED_List[67]].grid(row=5, column=19)
        globals()[LED_List[68]].grid(row=5, column=18)
        globals()[LED_List[69]].grid(row=6, column=18)
        globals()[LED_List[70]].grid(row=7, column=18)
        globals()[LED_List[71]].grid(row=7, column=17)
        globals()[LED_List[72]].grid(row=6, column=17)
        globals()[LED_List[73]].grid(row=5, column=17)
        globals()[LED_List[74]].grid(row=5, column=16)
        globals()[LED_List[75]].grid(row=6, column=16)
        globals()[LED_List[76]].grid(row=7, column=16)
        globals()[LED_List[77]].grid(row=7, column=15)
        globals()[LED_List[78]].grid(row=6, column=15)
        globals()[LED_List[79]].grid(row=5, column=15)
        globals()[LED_List[80]].grid(row=5, column=14)
        globals()[LED_List[81]].grid(row=6, column=14)
        globals()[LED_List[82]].grid(row=7, column=14)
        globals()[LED_List[83]].grid(row=7, column=13)
        globals()[LED_List[84]].grid(row=6, column=13)
        globals()[LED_List[85]].grid(row=5, column=13)
        globals()[LED_List[86]].grid(row=5, column=12)
        globals()[LED_List[87]].grid(row=6, column=12)
        globals()[LED_List[88]].grid(row=7, column=12)
        globals()[LED_List[89]].grid(row=7, column=11)
        globals()[LED_List[90]].grid(row=6, column=11)
        globals()[LED_List[91]].grid(row=5, column=11)
        globals()[LED_List[92]].grid(row=5, column=10)
        globals()[LED_List[93]].grid(row=6, column=10)
        globals()[LED_List[94]].grid(row=7, column=10)
        globals()[LED_List[95]].grid(row=7, column=9)
        globals()[LED_List[96]].grid(row=6, column=9)
        globals()[LED_List[97]].grid(row=5, column=9)
        globals()[LED_List[98]].grid(row=5, column=8)
        globals()[LED_List[99]].grid(row=6, column=8)
        globals()[LED_List[100]].grid(row=7, column=8)
        globals()[LED_List[101]].grid(row=7, column=7)
        globals()[LED_List[102]].grid(row=6, column=7)
        globals()[LED_List[103]].grid(row=5, column=7)
        globals()[LED_List[104]].grid(row=5, column=6)
        globals()[LED_List[105]].grid(row=6, column=6)
        globals()[LED_List[106]].grid(row=7, column=6)
        globals()[LED_List[107]].grid(row=7, column=5)
        globals()[LED_List[108]].grid(row=6, column=5)
        globals()[LED_List[109]].grid(row=5, column=5)
        globals()[LED_List[110]].grid(row=5, column=4)
        globals()[LED_List[111]].grid(row=6, column=4)
        globals()[LED_List[112]].grid(row=7, column=4)
        globals()[LED_List[113]].grid(row=7, column=3)
        globals()[LED_List[114]].grid(row=6, column=3)
        globals()[LED_List[115]].grid(row=5, column=3)
        globals()[LED_List[116]].grid(row=5, column=2)
        globals()[LED_List[117]].grid(row=6, column=2)
        globals()[LED_List[118]].grid(row=7, column=2)
        globals()[LED_List[119]].grid(row=6, column=1)

        #BS2 Widget Cluster
        globals()[LED_List[0]].grid(row=3, column=22)
        globals()[LED_List[1]].grid(row=2, column=21)
        globals()[LED_List[2]].grid(row=3, column=21)
        globals()[LED_List[3]].grid(row=3, column=20)
        globals()[LED_List[4]].grid(row=2, column=20)
        globals()[LED_List[5]].grid(row=1, column=20)
        globals()[LED_List[6]].grid(row=1, column=19)
        globals()[LED_List[7]].grid(row=3, column=19)
        globals()[LED_List[8]].grid(row=3, column=18)
        globals()[LED_List[9]].grid(row=2, column=18)
        globals()[LED_List[10]].grid(row=1, column=18)
        globals()[LED_List[11]].grid(row=1, column=17)
        globals()[LED_List[12]].grid(row=2, column=17)
        globals()[LED_List[13]].grid(row=3, column=17)
        globals()[LED_List[14]].grid(row=3, column=16)
        globals()[LED_List[15]].grid(row=2, column=16)
        globals()[LED_List[16]].grid(row=1, column=16)
        globals()[LED_List[17]].grid(row=1, column=15)
        globals()[LED_List[18]].grid(row=2, column=15)
        globals()[LED_List[19]].grid(row=3, column=15)
        globals()[LED_List[20]].grid(row=3, column=14)
        globals()[LED_List[21]].grid(row=2, column=14)
        globals()[LED_List[22]].grid(row=1, column=14)
        globals()[LED_List[23]].grid(row=1, column=13)
        globals()[LED_List[24]].grid(row=2, column=13)
        globals()[LED_List[25]].grid(row=3, column=13)
        globals()[LED_List[26]].grid(row=3, column=12)
        globals()[LED_List[27]].grid(row=2, column=12)
        globals()[LED_List[28]].grid(row=1, column=12)
        globals()[LED_List[29]].grid(row=1, column=11)
        globals()[LED_List[30]].grid(row=2, column=11)
        globals()[LED_List[31]].grid(row=3, column=11)
        globals()[LED_List[32]].grid(row=3, column=10)
        globals()[LED_List[33]].grid(row=2, column=10)
        globals()[LED_List[34]].grid(row=1, column=10)
        globals()[LED_List[35]].grid(row=1, column=9)
        globals()[LED_List[36]].grid(row=2, column=9)
        globals()[LED_List[37]].grid(row=3, column=9)
        globals()[LED_List[38]].grid(row=3, column=8)
        globals()[LED_List[39]].grid(row=2, column=8)
        globals()[LED_List[40]].grid(row=1, column=8)
        globals()[LED_List[41]].grid(row=1, column=7)
        globals()[LED_List[42]].grid(row=2, column=7)
        globals()[LED_List[43]].grid(row=3, column=7)
        globals()[LED_List[44]].grid(row=3, column=6)
        globals()[LED_List[45]].grid(row=2, column=6)
        globals()[LED_List[46]].grid(row=1, column=6)
        globals()[LED_List[47]].grid(row=1, column=5)
        globals()[LED_List[48]].grid(row=2, column=5)
        globals()[LED_List[49]].grid(row=3, column=5)
        globals()[LED_List[50]].grid(row=3, column=4)
        globals()[LED_List[51]].grid(row=2, column=4)
        globals()[LED_List[52]].grid(row=1, column=4)
        globals()[LED_List[53]].grid(row=1, column=3)
        globals()[LED_List[54]].grid(row=2, column=3)
        globals()[LED_List[55]].grid(row=3, column=3)
        globals()[LED_List[56]].grid(row=3, column=2)
        globals()[LED_List[57]].grid(row=2, column=2)
        globals()[LED_List[58]].grid(row=1, column=2)
        globals()[LED_List[59]].grid(row=2, column=1)

        #BS3 Widget Cluster
        globals()[LED_List[324]].grid(row=5, column=24)
        globals()[LED_List[325]].grid(row=6, column=25)
        globals()[LED_List[326]].grid(row=5, column=25)
        globals()[LED_List[327]].grid(row=5, column=26)
        globals()[LED_List[328]].grid(row=6, column=26)
        globals()[LED_List[329]].grid(row=7, column=26)
        globals()[LED_List[330]].grid(row=7, column=27)
        globals()[LED_List[331]].grid(row=5, column=27)
        globals()[LED_List[332]].grid(row=5, column=28)
        globals()[LED_List[333]].grid(row=6, column=28)
        globals()[LED_List[334]].grid(row=7, column=28)
        globals()[LED_List[335]].grid(row=7, column=29)
        globals()[LED_List[336]].grid(row=6, column=29)
        globals()[LED_List[337]].grid(row=5, column=29)
        globals()[LED_List[338]].grid(row=5, column=30)
        globals()[LED_List[339]].grid(row=6, column=30)
        globals()[LED_List[340]].grid(row=7, column=30)
        globals()[LED_List[341]].grid(row=7, column=31)
        globals()[LED_List[342]].grid(row=6, column=31)
        globals()[LED_List[343]].grid(row=5, column=31)
        globals()[LED_List[344]].grid(row=5, column=32)
        globals()[LED_List[345]].grid(row=6, column=32)
        globals()[LED_List[346]].grid(row=7, column=32)
        globals()[LED_List[347]].grid(row=7, column=33)
        globals()[LED_List[348]].grid(row=6, column=33)
        globals()[LED_List[349]].grid(row=5, column=33)
        globals()[LED_List[350]].grid(row=5, column=34)
        globals()[LED_List[351]].grid(row=6, column=34)
        globals()[LED_List[352]].grid(row=7, column=34)
        globals()[LED_List[353]].grid(row=7, column=35)
        globals()[LED_List[354]].grid(row=6, column=35)
        globals()[LED_List[355]].grid(row=5, column=35)
        globals()[LED_List[356]].grid(row=5, column=36)
        globals()[LED_List[357]].grid(row=6, column=36)
        globals()[LED_List[358]].grid(row=7, column=36)
        globals()[LED_List[359]].grid(row=7, column=37)
        globals()[LED_List[360]].grid(row=6, column=37)
        globals()[LED_List[361]].grid(row=5, column=37)
        globals()[LED_List[362]].grid(row=5, column=38)
        globals()[LED_List[363]].grid(row=6, column=38)
        globals()[LED_List[364]].grid(row=7, column=38)
        globals()[LED_List[365]].grid(row=7, column=39)
        globals()[LED_List[366]].grid(row=6, column=39)
        globals()[LED_List[367]].grid(row=5, column=39)
        globals()[LED_List[368]].grid(row=5, column=40)
        globals()[LED_List[369]].grid(row=6, column=40)
        globals()[LED_List[370]].grid(row=7, column=40)
        globals()[LED_List[371]].grid(row=7, column=41)
        globals()[LED_List[372]].grid(row=6, column=41)
        globals()[LED_List[373]].grid(row=5, column=41)
        globals()[LED_List[374]].grid(row=5, column=42)
        globals()[LED_List[375]].grid(row=6, column=42)
        globals()[LED_List[376]].grid(row=7, column=42)
        globals()[LED_List[377]].grid(row=7, column=43)
        globals()[LED_List[378]].grid(row=6, column=43)
        globals()[LED_List[379]].grid(row=5, column=43)
        globals()[LED_List[380]].grid(row=5, column=44)
        globals()[LED_List[381]].grid(row=6, column=44)
        globals()[LED_List[382]].grid(row=7, column=44)
        globals()[LED_List[383]].grid(row=6, column=45)

        #BS4 WidgetCluster
        globals()[LED_List[384]].grid(row=3, column=24)
        globals()[LED_List[385]].grid(row=2, column=25)
        globals()[LED_List[386]].grid(row=3, column=25)
        globals()[LED_List[387]].grid(row=3, column=26)
        globals()[LED_List[388]].grid(row=2, column=26)
        globals()[LED_List[389]].grid(row=1, column=26)
        globals()[LED_List[390]].grid(row=1, column=27)
        globals()[LED_List[391]].grid(row=3, column=27)
        globals()[LED_List[392]].grid(row=3, column=28)
        globals()[LED_List[393]].grid(row=2, column=28)
        globals()[LED_List[394]].grid(row=1, column=28)
        globals()[LED_List[395]].grid(row=1, column=29)
        globals()[LED_List[396]].grid(row=2, column=29)
        globals()[LED_List[397]].grid(row=3, column=29)
        globals()[LED_List[398]].grid(row=3, column=30)
        globals()[LED_List[399]].grid(row=2, column=30)
        globals()[LED_List[400]].grid(row=1, column=30)
        globals()[LED_List[401]].grid(row=1, column=31)
        globals()[LED_List[402]].grid(row=2, column=31)
        globals()[LED_List[403]].grid(row=3, column=31)
        globals()[LED_List[404]].grid(row=3, column=32)
        globals()[LED_List[405]].grid(row=2, column=32)
        globals()[LED_List[406]].grid(row=1, column=32)
        globals()[LED_List[407]].grid(row=1, column=33)
        globals()[LED_List[408]].grid(row=2, column=33)
        globals()[LED_List[409]].grid(row=3, column=33)
        globals()[LED_List[410]].grid(row=3, column=34)
        globals()[LED_List[411]].grid(row=2, column=34)
        globals()[LED_List[412]].grid(row=1, column=34)
        globals()[LED_List[413]].grid(row=1, column=35)
        globals()[LED_List[414]].grid(row=2, column=35)
        globals()[LED_List[415]].grid(row=3, column=35)
        globals()[LED_List[416]].grid(row=3, column=36)
        globals()[LED_List[417]].grid(row=2, column=36)
        globals()[LED_List[418]].grid(row=1, column=36)
        globals()[LED_List[419]].grid(row=1, column=37)
        globals()[LED_List[420]].grid(row=2, column=37)
        globals()[LED_List[421]].grid(row=3, column=37)
        globals()[LED_List[422]].grid(row=3, column=38)
        globals()[LED_List[423]].grid(row=2, column=38)
        globals()[LED_List[424]].grid(row=1, column=38)
        globals()[LED_List[425]].grid(row=1, column=39)
        globals()[LED_List[426]].grid(row=2, column=39)
        globals()[LED_List[427]].grid(row=3, column=39)
        globals()[LED_List[428]].grid(row=3, column=40)
        globals()[LED_List[429]].grid(row=2, column=40)
        globals()[LED_List[430]].grid(row=1, column=40)
        globals()[LED_List[431]].grid(row=1, column=41)
        globals()[LED_List[432]].grid(row=2, column=41)
        globals()[LED_List[433]].grid(row=3, column=41)
        globals()[LED_List[434]].grid(row=3, column=42)
        globals()[LED_List[435]].grid(row=2, column=42)
        globals()[LED_List[436]].grid(row=1, column=42)
        globals()[LED_List[437]].grid(row=1, column=43)
        globals()[LED_List[438]].grid(row=2, column=43)
        globals()[LED_List[439]].grid(row=3, column=43)
        globals()[LED_List[440]].grid(row=3, column=44)
        globals()[LED_List[441]].grid(row=2, column=44)
        globals()[LED_List[442]].grid(row=1, column=44)
        globals()[LED_List[443]].grid(row=2, column=45)

        #TS1 Widget Cluster
        globals()[LED_List[273]].grid(row=13, column=24)
        globals()[LED_List[274]].grid(row=14, column=24)
        globals()[LED_List[275]].grid(row=15, column=24)
        globals()[LED_List[276]].grid(row=15, column=25)
        globals()[LED_List[277]].grid(row=14, column=25)
        globals()[LED_List[278]].grid(row=13, column=25)
        globals()[LED_List[279]].grid(row=13, column=26)
        globals()[LED_List[280]].grid(row=15, column=26)
        globals()[LED_List[281]].grid(row=14, column=27)
        globals()[LED_List[282]].grid(row=13, column=28)
        globals()[LED_List[283]].grid(row=14, column=28)
        globals()[LED_List[284]].grid(row=15, column=28)
        globals()[LED_List[285]].grid(row=15, column=29)
        globals()[LED_List[286]].grid(row=14, column=29)
        globals()[LED_List[287]].grid(row=13, column=29)
        globals()[LED_List[288]].grid(row=13, column=30)
        globals()[LED_List[289]].grid(row=14, column=30)
        globals()[LED_List[290]].grid(row=15, column=30)
        globals()[LED_List[291]].grid(row=15, column=31)
        globals()[LED_List[292]].grid(row=14, column=31)
        globals()[LED_List[293]].grid(row=13, column=31)
        globals()[LED_List[294]].grid(row=13, column=32)
        globals()[LED_List[295]].grid(row=14, column=32)
        globals()[LED_List[296]].grid(row=15, column=32)
        globals()[LED_List[297]].grid(row=15, column=33)
        globals()[LED_List[298]].grid(row=14, column=33)
        globals()[LED_List[299]].grid(row=13, column=33)
        globals()[LED_List[300]].grid(row=13, column=34)
        globals()[LED_List[301]].grid(row=14, column=34)
        globals()[LED_List[302]].grid(row=15, column=34)
        globals()[LED_List[303]].grid(row=15, column=35)
        globals()[LED_List[304]].grid(row=14, column=35)
        globals()[LED_List[305]].grid(row=13, column=35)
        globals()[LED_List[306]].grid(row=13, column=36)
        globals()[LED_List[307]].grid(row=14, column=36)
        globals()[LED_List[308]].grid(row=15, column=36)
        globals()[LED_List[309]].grid(row=15, column=37)
        globals()[LED_List[310]].grid(row=14, column=37)
        globals()[LED_List[311]].grid(row=13, column=37)
        globals()[LED_List[312]].grid(row=13, column=38)
        globals()[LED_List[313]].grid(row=14, column=38)
        globals()[LED_List[314]].grid(row=15, column=38)
        globals()[LED_List[315]].grid(row=15, column=39)
        globals()[LED_List[316]].grid(row=14, column=39)
        globals()[LED_List[317]].grid(row=13, column=39)
        globals()[LED_List[318]].grid(row=13, column=40)
        globals()[LED_List[319]].grid(row=14, column=40)
        globals()[LED_List[320]].grid(row=15, column=40)
        globals()[LED_List[321]].grid(row=15, column=41)
        globals()[LED_List[322]].grid(row=14, column=41)
        globals()[LED_List[323]].grid(row=13, column=41)

        #TS2 Widget Cluster
        globals()[LED_List[222]].grid(row=9, column=24)
        globals()[LED_List[223]].grid(row=10, column=24)
        globals()[LED_List[224]].grid(row=11, column=24)
        globals()[LED_List[225]].grid(row=11, column=25)
        globals()[LED_List[226]].grid(row=10, column=25)
        globals()[LED_List[227]].grid(row=9, column=25)
        globals()[LED_List[228]].grid(row=9, column=26)
        globals()[LED_List[229]].grid(row=11, column=26)
        globals()[LED_List[230]].grid(row=10, column=27)
        globals()[LED_List[231]].grid(row=9, column=28)
        globals()[LED_List[232]].grid(row=10, column=28)
        globals()[LED_List[233]].grid(row=11, column=28)
        globals()[LED_List[234]].grid(row=11, column=29)
        globals()[LED_List[235]].grid(row=10, column=29)
        globals()[LED_List[236]].grid(row=9, column=29)
        globals()[LED_List[237]].grid(row=9, column=30)
        globals()[LED_List[238]].grid(row=10, column=30)
        globals()[LED_List[239]].grid(row=11, column=30)
        globals()[LED_List[240]].grid(row=11, column=31)
        globals()[LED_List[241]].grid(row=10, column=31)
        globals()[LED_List[242]].grid(row=9, column=31)
        globals()[LED_List[243]].grid(row=9, column=32)
        globals()[LED_List[244]].grid(row=10, column=32)
        globals()[LED_List[245]].grid(row=11, column=32)
        globals()[LED_List[246]].grid(row=11, column=33)
        globals()[LED_List[247]].grid(row=10, column=33)
        globals()[LED_List[248]].grid(row=9, column=33)
        globals()[LED_List[249]].grid(row=9, column=34)
        globals()[LED_List[250]].grid(row=10, column=34)
        globals()[LED_List[251]].grid(row=11, column=34)
        globals()[LED_List[252]].grid(row=11, column=35)
        globals()[LED_List[253]].grid(row=10, column=35)
        globals()[LED_List[254]].grid(row=9, column=35)
        globals()[LED_List[255]].grid(row=9, column=36)
        globals()[LED_List[256]].grid(row=10, column=36)
        globals()[LED_List[257]].grid(row=11, column=36)
        globals()[LED_List[258]].grid(row=11, column=37)
        globals()[LED_List[259]].grid(row=10, column=37)
        globals()[LED_List[260]].grid(row=9, column=37)
        globals()[LED_List[261]].grid(row=9, column=38)
        globals()[LED_List[262]].grid(row=10, column=38)
        globals()[LED_List[263]].grid(row=11, column=38)
        globals()[LED_List[264]].grid(row=11, column=39)
        globals()[LED_List[265]].grid(row=10, column=39)
        globals()[LED_List[266]].grid(row=9, column=39)
        globals()[LED_List[267]].grid(row=9, column=40)
        globals()[LED_List[268]].grid(row=10, column=40)
        globals()[LED_List[269]].grid(row=11, column=40)
        globals()[LED_List[270]].grid(row=11, column=41)
        globals()[LED_List[271]].grid(row=10, column=41)
        globals()[LED_List[272]].grid(row=9, column=41)

        #TS3 Widget Cluster
        globals()[LED_List[120]].grid(row=15, column=22)
        globals()[LED_List[121]].grid(row=14, column=22)
        globals()[LED_List[122]].grid(row=13, column=22)
        globals()[LED_List[123]].grid(row=13, column=21)
        globals()[LED_List[124]].grid(row=14, column=21)
        globals()[LED_List[125]].grid(row=15, column=21)
        globals()[LED_List[126]].grid(row=15, column=20)
        globals()[LED_List[127]].grid(row=13, column=20)
        globals()[LED_List[128]].grid(row=14, column=19)
        globals()[LED_List[129]].grid(row=15, column=18)
        globals()[LED_List[130]].grid(row=14, column=18)
        globals()[LED_List[131]].grid(row=13, column=18)
        globals()[LED_List[132]].grid(row=13, column=17)
        globals()[LED_List[133]].grid(row=14, column=17)
        globals()[LED_List[134]].grid(row=15, column=17)
        globals()[LED_List[135]].grid(row=15, column=16)
        globals()[LED_List[136]].grid(row=14, column=16)
        globals()[LED_List[137]].grid(row=13, column=16)
        globals()[LED_List[138]].grid(row=13, column=15)
        globals()[LED_List[139]].grid(row=14, column=15)
        globals()[LED_List[140]].grid(row=15, column=15)
        globals()[LED_List[141]].grid(row=15, column=14)
        globals()[LED_List[142]].grid(row=14, column=14)
        globals()[LED_List[143]].grid(row=13, column=14)
        globals()[LED_List[144]].grid(row=13, column=13)
        globals()[LED_List[145]].grid(row=14, column=13)
        globals()[LED_List[146]].grid(row=15, column=13)
        globals()[LED_List[147]].grid(row=15, column=12)
        globals()[LED_List[148]].grid(row=14, column=12)
        globals()[LED_List[149]].grid(row=13, column=12)
        globals()[LED_List[150]].grid(row=13, column=11)
        globals()[LED_List[151]].grid(row=14, column=11)
        globals()[LED_List[152]].grid(row=15, column=11)
        globals()[LED_List[153]].grid(row=15, column=10)
        globals()[LED_List[154]].grid(row=14, column=10)
        globals()[LED_List[155]].grid(row=13, column=10)
        globals()[LED_List[156]].grid(row=13, column=9)
        globals()[LED_List[157]].grid(row=14, column=9)
        globals()[LED_List[158]].grid(row=15, column=9)
        globals()[LED_List[159]].grid(row=15, column=8)
        globals()[LED_List[160]].grid(row=14, column=8)
        globals()[LED_List[161]].grid(row=13, column=8)
        globals()[LED_List[162]].grid(row=13, column=7)
        globals()[LED_List[163]].grid(row=14, column=7)
        globals()[LED_List[164]].grid(row=15, column=7)
        globals()[LED_List[165]].grid(row=15, column=6)
        globals()[LED_List[166]].grid(row=14, column=6)
        globals()[LED_List[167]].grid(row=13, column=6)
        globals()[LED_List[168]].grid(row=13, column=5)
        globals()[LED_List[169]].grid(row=14, column=5)
        globals()[LED_List[170]].grid(row=15, column=5)

        #TS4 Widget Cluster
        globals()[LED_List[171]].grid(row=11, column=22)
        globals()[LED_List[172]].grid(row=10, column=22)
        globals()[LED_List[173]].grid(row=9, column=22)
        globals()[LED_List[174]].grid(row=9, column=21)
        globals()[LED_List[175]].grid(row=10, column=21)
        globals()[LED_List[176]].grid(row=11, column=21)
        globals()[LED_List[177]].grid(row=11, column=20)
        globals()[LED_List[178]].grid(row=9, column=20)
        globals()[LED_List[179]].grid(row=10, column=19)
        globals()[LED_List[180]].grid(row=11, column=18)
        globals()[LED_List[181]].grid(row=10, column=18)
        globals()[LED_List[182]].grid(row=9, column=18)
        globals()[LED_List[183]].grid(row=9, column=17)
        globals()[LED_List[184]].grid(row=10, column=17)
        globals()[LED_List[185]].grid(row=11, column=17)
        globals()[LED_List[186]].grid(row=11, column=16)
        globals()[LED_List[187]].grid(row=10, column=16)
        globals()[LED_List[188]].grid(row=9, column=16)
        globals()[LED_List[189]].grid(row=9, column=15)
        globals()[LED_List[190]].grid(row=10, column=15)
        globals()[LED_List[191]].grid(row=11, column=15)
        globals()[LED_List[192]].grid(row=11, column=14)
        globals()[LED_List[193]].grid(row=10, column=14)
        globals()[LED_List[194]].grid(row=9, column=14)
        globals()[LED_List[195]].grid(row=9, column=13)
        globals()[LED_List[196]].grid(row=10, column=13)
        globals()[LED_List[197]].grid(row=11, column=13)
        globals()[LED_List[198]].grid(row=11, column=12)
        globals()[LED_List[199]].grid(row=10, column=12)
        globals()[LED_List[200]].grid(row=9, column=12)
        globals()[LED_List[201]].grid(row=9, column=11)
        globals()[LED_List[202]].grid(row=10, column=11)
        globals()[LED_List[203]].grid(row=11, column=11)
        globals()[LED_List[204]].grid(row=11, column=10)
        globals()[LED_List[205]].grid(row=10, column=10)
        globals()[LED_List[206]].grid(row=9, column=10)
        globals()[LED_List[207]].grid(row=9, column=9)
        globals()[LED_List[208]].grid(row=10, column=9)
        globals()[LED_List[209]].grid(row=11, column=9)
        globals()[LED_List[210]].grid(row=11, column=8)
        globals()[LED_List[211]].grid(row=10, column=8)
        globals()[LED_List[212]].grid(row=9, column=8)
        globals()[LED_List[213]].grid(row=9, column=7)
        globals()[LED_List[214]].grid(row=10, column=7)
        globals()[LED_List[215]].grid(row=11, column=7)
        globals()[LED_List[216]].grid(row=11, column=6)
        globals()[LED_List[217]].grid(row=10, column=6)
        globals()[LED_List[218]].grid(row=9, column=6)
        globals()[LED_List[219]].grid(row=9, column=5)
        globals()[LED_List[220]].grid(row=10, column=5)
        globals()[LED_List[221]].grid(row=11, column=5)
ch_button_show_hex = tk.Button(character_frame, text="Show Hex", command=lambda: b_show_hex())
ch_button_show_hex.place(relwidth=0.1, height=20, relx=0.28)

ch_button_add = tk.Button(character_frame, text="Add", command=lambda: b_add_row())
ch_button_add.place(relwidth=0.15, height=20, relx=0.4)

ch_button_delete = tk.Button(character_frame, text="Delete", command=lambda: b_delete_row())
ch_button_delete.place(relwidth=0.15, height=20, relx=0.57)

ch_button_preview = tk.Button(character_frame, text="Preview", command=lambda: get_preview(root))
ch_button_preview.place(relwidth=0.15, height=20, relx=0.74)

zoom_var = StringVar(character_frame)
zoom_var.set("x1")
zoom_list = OptionMenu(character_frame, zoom_var, "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10")
zoom_list.place(relwidth=0.07, height=20, relx=0.9)



ch_frame = tk.Frame(character_frame, bg='light blue')
ch_frame.place(relx=0.01, rely=0.2, relwidth=0.99, relheight=0.84)

sp_ch_frame = tk.Frame(sp_character_frame, bg='light blue')
sp_ch_frame.place(relx=0.01, rely=0.2, relwidth=0.99, relheight=0.84)

model = TableModel()
table = TableCanvas(ch_frame, model=model)
table.show()

model2 = TableModel()
table2 = TableCanvas(sp_ch_frame, model=model2, read_only=True)
示例#23
0
A2.place(x=120, y=202)
A3 = Entry(root, textvar=city)
A3.place(x=120, y=222)
A4 = Entry(root, textvar=pincode)
A4.place(x=120, y=242)
A5 = Entry(root, textvar=state)
A5.place(x=310, y=222)

countries = [
    "Argentina", "Australia", "Brazil", "Canada", "China", 'Germany', 'France',
    "India", "Indonesia", "Italy", "Japan", "Mexico", "the Russian Federation",
    "Saudi Arabia", "South Africa", "South Korea", "Turkey", "the UK", "the US"
]
countryDropList = OptionMenu(root, country, *countries)
countryDropList.config(width=10)
countryDropList.place(x=310, y=242)
country.set('Please Select')

Entry(
    root,
    textvar=email,
    width=30,
).place(x=120, y=262)

Radiobutton(root,
            text="Gen",
            padx=20,
            variable=category,
            value='Gen',
            font=("Ubuntu", 11)).place(x=120, y=282)
Radiobutton(root,
示例#24
0
    def draw_window(self):
        '''
        Draws the Option Menu Window
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None.
    
        '''

        # Popup for the Option Menu
        self.option_window = tk.Toplevel()
        self.option_window.grab_set()
        self.option_window.wm_title("Options")
        self.option_window.geometry("%dx%d" %
                                    (self.window_width, self.window_height))

        # Window Background Frame
        self.background = Frame(self.option_window,
                                width=self.window_width,
                                height=self.window_height,
                                bg='white')
        self.background.place(x=0,
                              y=0,
                              width=self.window_width,
                              height=self.window_height)

        # Build the Interface (Drop-Down Menu) for the Window Resize Function
        label = Label(self.background,
                      text='Option Menu',
                      font='Helvetica 12 bold',
                      bg='white')
        label.place(x=self.window_width / 2 - 30, y=10)

        label = Label(self.background,
                      text='Window Size',
                      font='Helvetica 10 bold',
                      bg='white')
        label.place(x=10, y=50)

        self.selected_size = StringVar(self.background)
        self.selected_size.set(
            self.root_app.window_size_strings[self.root_app.window_size_index])
        option_menu = OptionMenu(self.background, self.selected_size,
                                 *self.root_app.window_size_strings)
        option_menu.place(x=110, y=50, width=100, height=25)

        # Ok/Cancel Buttons
        button = Button(self.background, text='Ok', command=self.ok_button)
        button.place(x=self.window_width / 2 - 110,
                     y=self.window_height - 50,
                     width=100,
                     height=25)

        button = Button(self.background,
                        text='Cancel',
                        command=self.option_window.destroy)
        button.place(x=self.window_width / 2 + 10,
                     y=self.window_height - 50,
                     width=100,
                     height=25)

        return True
示例#25
0
class App:
    def __init__(self, root):
        self.root = root
        self.root.title("Translate text")
        icon_photo = PhotoImage(file="app_icon.png")
        self.root.iconphoto(False, icon_photo)
        width = 510
        height = 500
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2,
                                    (screenheight - height) / 2)
        self.root.geometry(alignstr)
        self.root.resizable(width=False, height=False)
        self.ft = tkFont.Font(family='Sans-Serif', size=10)

        self.app_title = Label(root)
        self.app_title["font"] = tkFont.Font(family='Sans-Serif', size=38)
        self.app_title["fg"] = "#000000"
        self.app_title["justify"] = "left"
        self.app_title["text"] = "Translate text"
        self.app_title.place(x=10, y=10, width=320, height=44)

        # self.translate_from_entry=Entry(root)
        # self.translate_from_entry["bg"] = "#ffffff"
        # self.translate_from_entry["borderwidth"] = "4px"
        # self.translate_from_entry["font"] = self.ft
        # self.translate_from_entry["fg"] = "#000000"
        # self.translate_from_entry["justify"] = "left"
        # self.translate_from_entry.place(x=10,y=100,width=179,height=30)

        self.translate_from_var = StringVar(root)
        self.translate_from_var.set("Auto")  # default value
        self.translate_from_entry = OptionMenu(root, self.translate_from_var,
                                               *list(languages.keys()))
        self.translate_from_entry["font"] = self.ft
        self.translate_from_entry["justify"] = "left"
        self.translate_from_entry.place(x=10, y=100, width=179, height=30)

        self.translate_from_label = Label(root)
        self.translate_from_label["font"] = self.ft
        self.translate_from_label["fg"] = "#000000"
        self.translate_from_label["justify"] = "left"
        self.translate_from_label["text"] = "Translate from:"
        self.translate_from_label.place(x=10, y=70, width=98, height=30)

        self.translate_to_var = StringVar(root)
        self.translate_to_var.set("English")  # default value
        self.translate_to_entry = OptionMenu(root, self.translate_to_var,
                                             *list(languages.keys())[:-1])
        self.translate_to_entry["font"] = self.ft
        self.translate_to_entry["justify"] = "left"
        self.translate_to_entry.place(x=240, y=100, width=175, height=30)

        self.translate_to_label = Label(root)
        self.translate_to_label["font"] = self.ft
        self.translate_to_label["fg"] = "#000000"
        self.translate_to_label["justify"] = "left"
        self.translate_to_label["text"] = "Translate to:"
        self.translate_to_label.place(x=240, y=70, width=70, height=25)

        self.translate_text = Text(root)
        self.translate_text["bg"] = "#ffffff"
        self.translate_text["borderwidth"] = "4px"
        self.translate_text["font"] = self.ft
        self.translate_text["fg"] = "#000000"
        self.translate_text.place(x=10, y=160, width=182, height=294)

        self.translated_text = Text(root)
        self.translated_text["bg"] = "#ffffff"
        self.translated_text["borderwidth"] = "4px"
        self.translated_text["font"] = self.ft
        self.translated_text["fg"] = "#000000"
        self.translated_text["state"] = "disabled"
        self.translated_text.place(x=240, y=160, width=173, height=295)

        self.translate_button = Button(root)
        self.translate_button["bg"] = "#efefef"
        self.translate_button["font"] = self.ft
        self.translate_button["fg"] = "#000000"
        self.translate_button["justify"] = "center"
        self.translate_button["text"] = "Translate!"
        self.translate_button.place(x=430, y=100, width=67, height=30)
        self.translate_button["command"] = self.translate_button_command

    def translate_button_command(self):
        language_from = languages[self.translate_from_var.get()]
        language_to = languages[self.translate_to_var.get()]
        translate_str = self.translate_text.get("1.0", END)

        try:
            html = request.urlopen(
                f"https://translate.googleapis.com/translate_a/single?client=gtx&sl={language_from}&tl={language_to}&dt=t&q={parse.quote_plus(translate_str)}"
            ).read().decode("utf8")
        except:
            showinfo("An error occurred",
                     "An error occurred. Please try again later.")

        translated_text = ""

        for sentence in loads(html)[0]:
            translated_text += sentence[0]

        self.translated_text["state"] = "normal"
        self.translated_text.delete('1.0', END)
        self.translated_text.insert("1.0", translated_text)
        self.translated_text["state"] = "disabled"
示例#26
0
    def __init__(self, master, title, x_coor, y_coor, data, variant=False):
        self.__chb_var = IntVar()
        self.__state = StringVar()
        self.__count = StringVar()
        self.__xObs = StringVar()
        self.__p_value = StringVar()
        self.__result = StringVar()
        self.__results = []
        self.__variant = variant

        checkbox = Checkbutton(master, text=title, variable=self.__chb_var)
        checkbox.place(x=x_coor, y=y_coor)

        state_label = LabelTag(master,
                               'State', (x_coor + 60), (y_coor + 30),
                               width=100,
                               font_size=12,
                               border=2,
                               relief='groove')
        if variant:
            self.__state.set('-1.0')
        else:
            self.__state.set('+1')
        state_option = OptionMenu(master, self.__state, *data)
        state_option.place(x=(x_coor + 60),
                           y=(y_coor + 60),
                           height=25,
                           width=100)
        if not variant:
            xObs_label = LabelTag(master,
                                  'CHI-SQUARED', (x_coor + 165), (y_coor + 30),
                                  width=350,
                                  font_size=12,
                                  border=2,
                                  relief='groove')
            xObs_Entry = Entry(master, textvariable=self.__xObs)
            xObs_Entry.place(x=(x_coor + 165),
                             y=(y_coor + 60),
                             width=350,
                             height=25)
        else:
            count_label = LabelTag(master,
                                   'Count', (x_coor + 165), (y_coor + 30),
                                   width=350,
                                   font_size=12,
                                   border=2,
                                   relief='groove')
            count_Entry = Entry(master, textvariable=self.__count)
            count_Entry.place(x=(x_coor + 165),
                              y=(y_coor + 60),
                              width=350,
                              height=25)
            pass
        p_value_label = LabelTag(master,
                                 'P-Value', (x_coor + 520), (y_coor + 30),
                                 width=350,
                                 font_size=12,
                                 border=2,
                                 relief='groove')
        p_value_Entry = Entry(master, textvariable=self.__p_value)
        p_value_Entry.place(x=(x_coor + 520),
                            y=(y_coor + 60),
                            width=350,
                            height=25)
        conclusion_label = LabelTag(master,
                                    'Conclusion', (x_coor + 875),
                                    (y_coor + 30),
                                    width=150,
                                    font_size=12,
                                    border=2,
                                    relief='groove')
        conclusion_Entry = Entry(master, textvariable=self.__result)
        conclusion_Entry.place(x=(x_coor + 875),
                               y=(y_coor + 60),
                               width=150,
                               height=25)

        update_button = Button(master, text='Update', command=self.update)
        update_button.config(font=("Calibri", 10))
        update_button.place(x=(x_coor + 1030),
                            y=(y_coor + 60),
                            width=180,
                            height=25)
示例#27
0
class Application(object):

    def __init__(self):

        self.master = Tk()
        self.master.geometry(newGeometry = '300x300')
        # Fenêtre tkinter

        self.menu = Menu(self.master)

        self.filemenu = Menu(self.menu,
                             tearoff = 0)
        self.filemenu.add_command(label = "Open", command = self.open)
        self.filemenu.add_separator()
        self.filemenu.add_command(label = "Exit", command = self.master.destroy)
        self.menu.add_cascade(label = "File",
                              menu = self.filemenu)

        self.master.config(menu = self.menu)
        # On crée un menu

        self.canvas = Canvas(master=self.master,
                             width=200,
                             height=200,
                             bg='#cccccc')

        self.canvas.place(x=150,
                          y=100,
                          anchor='center')

        Label(master=self.master,
              text='Image',
              font='YuMinchoDemibold',
              foreground='white',
              background='#535353').place(x=120,
                                          y=190)

    def open(self):

        self.image_path = askopenfilename(initialdir = os.path.dirname(os.path.join(os.getcwd(), __file__)),
                                          filetypes = (("png files",".png"),
                                                       ("jpg files",".jpg"),
                                                       ("all files (risk)", ".")),
                                          defaultextension = ".png",
                                          title = "Open picture file")
        # on demande le fichier à ouvrir

        if self.image_path == "":
            # Si l'utilisateur choisit annuler
            return None
        else:
            pass

        self.pyimage = PhotoImage(file = self.image_path)
        print(self.image_path)
        self.PILimage = pil.open(self.image_path)

        if self.PILimage.size[0] > 200 or\
           self.PILimage.size[1] > 200:

            if self.PILimage.size[0] >= self.PILimage.size[1]:
                x = 200
                pourcentage = int(((200*100)/self.PILimage.size[0]))
                y = self.PILimage.size[1] - (self.PILimage.size[1]* (100 - pourcentage) /100)
            else:
                y = 200
                pourcentage = int(((200 * 100) / self.PILimage.size[1]))
                x = self.PILimage.size[0] - (self.PILimage.size[0] * (100 - pourcentage) / 100)

            Label(master = self.master,
                  text = 'Image resized \nfor view ({}%)'.format(pourcentage),
                  font = 'YuMinchoDemibold 6',
                  fg = 'black').place(x=190,y=200)
            print('cc3')
            self.PILimage.resize((int(x),int(y)), pil.BILINEAR).save("tmp.png")
            self.pyimage = PhotoImage(file="tmp.png")
            os.remove('tmp.png')
            # On redimensionne l'image pour la preview

        self.image_tag = self.canvas.create_image(100,
                                                  100,
                                                  anchor = 'center',
                                                  image = self.pyimage)
        # On affiche l'image

        Label(master = self.master,
              text = 'Image original size:',
              font = 'YuMinchoDemibold 7',
              relief = 'groove').place(x = 20, y = 230)
        Label(master=self.master,
              text='({},{})'.format(self.PILimage.size[0],self.PILimage.size[1]),
              font='YuMinchoDemibold 8').place(x=37, y=250)

        Label(master=self.master,
              text='Choisir taille thumbnail:',
              font='YuMinchoDemibold 7',
              relief='groove').place(x=140, y=230)

        liste_valeurs = (30,50,100)

        self.taille_var = IntVar()
        self.menu_taille = OptionMenu(self.master,
                                      self.taille_var,
                                      *liste_valeurs)
        self.menu_taille.place(x=140, y=250)

        Button(master = self.master,
               text = 'Créer Thumbnail',
               font = 'YuMinchoDemibold 8',
               command = self.create_thumbnail).place(x=300,y=300,anchor='se')

    def create_thumbnail(self):

        if self.PILimage.size[0] >= self.PILimage.size[1]:
            x = self.taille_var.get()
            pourcentage = int(((x*100)/self.PILimage.size[0]))
            y = int(self.PILimage.size[1] - (self.PILimage.size[1] * (100-pourcentage)/100))
        else:
            y = self.taille_var.get()
            pourcentage = int(((y * 100) / self.PILimage.size[1]))
            x = int(self.PILimage.size[0] - (self.PILimage.size[0] * (100-pourcentage)/100))
        # On récupère les valeurs

        name = self.image_path.split('/')[-1].split(".")
        name = name[0] + 'THUMBNAIL.' + name[1]
        self.PILimage.resize((x,y),pil.BILINEAR).save(name)
#SETTINGS
settings_h = Label(root, text="Settings")
settings_h.config(font=headerfont)
settings_h.place(x=1100, y=widget_heigt + 100)

# Create a Tkinter variable
rotation_var = StringVar()

# Dictionary with options
choices = {'on', 'off'}
rotation_var.set('off')  # set the default option

popupMenu = OptionMenu(root, rotation_var, *choices)
Label(root, text="Rotation").place(x=1100, y=widget_heigt + 130)
popupMenu.place(x=1180, y=widget_heigt + 130)


# on change dropdown value
def change_dropdown(*args):
    global t
    if rotation_var.get() == "on":
        t = 7
    elif rotation_var.get() == "off":
        t = 1
    else:
        return None


# link function to change dropdown
rotation_var.trace('w', change_dropdown)
示例#29
0
class MyFirstGUI:
    ticks = sorted([
        'S', 'WMT', 'VZ', 'RHT', 'DIS', 'JPM', 'BA', 'AMZN', 'PEP', 'ORCL',
        'DAL'
    ])

    def __init__(self, mw):
        self.style = ttk.Style()
        print(self.style.theme_names())
        self.style.theme_use('vista')
        self.num = 15
        self.mw = mw
        mw.title("Optymalizacja omega")
        mw.geometry("700x700")  # You want the size of the app to be 700x700
        mw.resizable(0, 0)
        self.mystring = tk.StringVar(mw, '100')
        self.mystring2 = tk.StringVar(mw, '0')
        self.evalext_str = tk.StringVar(mw, '1')
        self.weights = []
        self.tickers = []
        self.max_number = tk.StringVar(mw, 3)
        self.freq = tk.StringVar(mw, 'roczny')
        self.label = Label(mw, text="Optymalizacja omega", font='Helvatica')
        self.label.pack()
        self.labelmax = Label(text="Max Udział").place(x=25, y=25)
        self.labelmax = Label(text="%").place(x=110, y=45)
        self.labelmax = Label(text="%").place(x=110, y=25)
        self.inputmax = Entry(text="1",
                              textvariable=self.mystring).place(x=90,
                                                                y=25,
                                                                width=20)
        self.labelmin = Label(text="Min Udział ").place(x=25, y=45)
        self.inputmin = Entry(textvariable=self.mystring2).place(x=90,
                                                                 y=45,
                                                                 width=20)
        self.var = tk.StringVar(mw)
        self.var.set('25')  # initial value
        self.option = Entry(text="1", textvariable=self.var).place(x=550,
                                                                   y=30,
                                                                   width=60)
        self.option = OptionMenu(mw, self.freq, "roczny",
                                 "miesieczny").place(x=440, y=28, width=100)
        Label(text="Cel:", font='Times').place(x=400, y=30)
        Label(text="%", font='Times').place(x=640, y=30)
        self.close_button = Button(mw, text="Zamknij",
                                   command=mw.quit).place(y=650, x=450)
        for i in (range(self.num)):
            self.weights.append(tk.StringVar(mw, '0'))
            self.tickers.append(tk.StringVar(mw, ''))
            Entry(textvariable=self.weights[i],
                  state=tk.DISABLED).place(x=250, y=100 + i * 30, width=30)
            Entry(textvariable=self.tickers[i]).place(x=200,
                                                      y=100 + i * 30,
                                                      width=50)
            Label(text="%").place(x=280, y=100 + i * 30)
            Label(text="Akcja " + str(i + 1)).place(x=150, y=100 + i * 30)
            j = 0
        for i in self.ticks:
            self.tickers[j].set(i)
            j = j + 1

        Button(mw, text="Optymalizuj", command=self.optimize).place(x=120,
                                                                    y=550,
                                                                    width=100)
        self.graph_btn = Button(mw,
                                text="Pokaż wykres",
                                state=tk.DISABLED,
                                command=self.draw)
        self.table_btn = Button(mw,
                                text="Rysuj tabele",
                                state=tk.DISABLED,
                                command=self.table)
        self.eval_button = Button(mw,
                                  text='Zmiany akcji',
                                  command=self.eval_portfolio)
        self.evalext_button = Button(mw,
                                     text='Zmiany portfolio',
                                     command=self.evalext_portfolio,
                                     state=tk.DISABLED)
        self.evalext_entry = Entry(textvariable=self.evalext_str).place(
            x=560, y=525, width=20)
        Label(text="Pokaz", font='Times').place(x=510, y=525)
        Label(text="lat po okresie", font='Times').place(x=585, y=525)

        self.graph_btn.place(x=220, y=550, width=100)
        self.table_btn.place(x=320, y=550, width=100)
        self.eval_button.place(x=420, y=550, width=100)
        self.evalext_button.place(x=520, y=550, width=100)

        self.yearfrom = tk.StringVar(mw)
        self.method = tk.StringVar(mw)
        self.yearfrom.set('2010')  # initial value
        self.option = OptionMenu(mw, self.yearfrom, "1980", "1990", "1995",
                                 "2000", "2003", "2005", "2008", "2010",
                                 "2012", "2013", "2014",
                                 "2015").place(x=470, y=75, width=80)
        self.option = OptionMenu(mw,
                                 self.method,
                                 "SLSQP",
                                 "lin",
                                 "elin",
                                 "lin_lmt",
                                 "lin_safe",
                                 command=self.change_opt)
        self.option.place(x=510, y=115, width=80)
        self.yearto = tk.StringVar(mw)
        self.yearto.set('2016')  # initial value
        self.method.set('lin')
        self.option = OptionMenu(mw, self.yearto, "2000", "2003", "2005",
                                 "2008", "2010", "2012", "2015", "2016",
                                 "2017").place(x=570, y=75, width=80)
        Label(text="Dane od roku:").place(x=390, y=80)
        Label(text="Metoda Optymalizacji:").place(x=390, y=125)
        Label(text="do", ).place(x=550, y=80)
        self.status = tk.StringVar(mw, 'Wprowadz dane do optymalizacji !')
        Entry(textvariable=self.status, state=tk.DISABLED).place(x=225,
                                                                 y=600,
                                                                 width=300)
        self.max_entry = Entry(mw,
                               textvariable=self.max_number,
                               state=tk.DISABLED)
        self.max_entry.place(x=510, y=160, width=50)
        Label(text="Limit pozycji:", font='Times').place(x=410, y=160)
        Label(text="Status:", font='Times').place(x=160, y=595)
        '''
        img = ImageTk.PhotoImage(Image.open('pobrane.jpg'))
        self.panel= Label(mw,image=img)
        self.panel.image=img

        #self.panel.pack(side="bottom", fill="both", expand="yes")
        self.panel.place(x=500, y=250,width=300,height=400)
         '''

    def change_opt(self, event):
        if (self.method.get() == 'lin_lmt' or self.method.get() == 'lin_safe'):
            self.max_entry.configure(state="normal")

        else:
            self.max_entry.configure(state=tk.DISABLED)
            a = 0

    def greet(self):
        print(self.mystring.get())

    def draw(self):

        con.draw_portfolios_omega(self.returns, self.tick, self.sol)

    def table(self):
        con.draw_table(self.returns, self.sol)

    def eval_portfolio(self):
        self.tick = []
        for i in range(len(self.tickers)):
            if self.tickers[i].get() != '':
                self.tick.append(self.tickers[i].get().upper())
        con.eval_results(self.tick, int(self.yearfrom.get()),
                         int(self.yearto.get()))

    def evalext_portfolio(self):
        self.tick = []
        yearsaft = self.evalext_str.get()

        years_int = 0
        error = 0
        try:
            years_int = int(yearsaft)
            if int(self.yearto.get()) + years_int > 2017:
                self.status.set(
                    'Nieprawidłowy okres (dane tylko do konca 2017)')
                error = 1

        except:
            self.status.set('Podano nieprawidłową liczbe lat okresu po')
            error = 1

        if error == 0:
            for i in range(len(self.tickers)):
                if self.tickers[i].get() != '':
                    self.tick.append(self.tickers[i].get().upper())
            try:
                con.eval_portfolio(self.tick, int(self.yearfrom.get()),
                                   int(self.yearto.get()), years_int, self.sol)
            except:
                self.status.set('Podano nieprawidłową ID firm lub okres')

    def optimize(self):
        self.status.set('Optymalizuje')
        self.tick = []
        error = 0
        maxs = self.mystring.get()
        mins = self.mystring2.get()
        Ks = self.max_number.get()
        try:
            K = int(Ks)
            max = float(maxs) / 100
            min = float(mins) / 100
            if max < 0.3:
                self.status.set('Za mała wartość maksymalnego udziału')
                error = 1
            if min > 0.3:
                self.status.set('Za duża wartość minimalnego udziału')
                error = 1

        except:
            self.status.set('Podano niepoprawne wartosci ograniczen ')
            error = 1

        if error == 0:

            target = self.var.get()

            if target != 'srednia':
                try:
                    float(target)
                    target = float(self.var.get())

                except ValueError:
                    self.var.set('Błąd!!')
                    self.status.set('Podano niepoprawny cel')

                    return

                con.set_target(target / 100)

            for i in range(len(self.tickers)):
                if self.tickers[i].get() != '':
                    self.tick.append(self.tickers[i].get().upper())
            try:
                if self.freq.get() == 'roczny':
                    self.returns = con.year_returns(self.tick,
                                                    int(self.yearfrom.get()),
                                                    int(self.yearto.get()))
                else:
                    self.returns = con.month_returns(self.tick,
                                                     int(self.yearfrom.get()),
                                                     int(self.yearto.get()))

            except:
                self.status.set('Podano niepoprawne ID firm')
                error = 1

        if error == 0:
            con.set_returns(self.returns)
            if (self.var.get() == 'srednia'):
                con.set_average(self.returns)
            try:
                self.sol = con.optimize(ratio='omega',
                                        method=self.method.get(),
                                        minW=min,
                                        maxW=max,
                                        K=K)
            except:
                self.status.set('Błąd optymlizacji')
                error = 1

            if self.sol is None or len(self.sol) < 1:
                self.status.set('Błąd optymlizacji')
                error = 1

            if error == 0:
                sol2 = copy.deepcopy(self.sol)
                tick = sorted(self.tick)
                for j in range(len(tick)):
                    sol2[j] = sol2[j] * 100
                    self.tickers[j].set(tick[j])
                    self.weights[j].set('{0:.4f}'.format(sol2[j]))
                self.graph_btn.configure(state="normal")
                self.table_btn.configure(state="normal")
                self.evalext_button.configure(state="normal")
                for k in range(len(tick), len(self.tickers)):
                    self.weights[k].set('{0:.4f}'.format(0.00))

                if sol2[1] is not None and not np.isnan(sol2[1]):
                    self.status.set('Zoptymalizowano !')
                else:
                    self.status.set('nie udalo sie znaleźc rozwiazania')
    file_name.set(file_name_)


root = Tk()
root.title(u"Auto Speech2Text")
root.geometry("300x240+200+200")
root.resizable(False, False)

lang_label = Label(text=u'Select audio language')
# lang_label.config(font=("Courier", 12))
lang_label.place(x=30, y=20)
lang_code = StringVar(root)
lang_code.set(u"中文(繁體)")
lang = OptionMenu(root, lang_code, *LANG_CODE_DICT.keys())
# lang.config(font=("Courier", 12), width=8)
lang.place(x=20, y=50)

file_button = Button(text=u'Select API key', command=choose_file)
# file_button.config(font=("Courier", 12))
file_button.place(x=24, y=110)
file_name = StringVar()
file_name.set('')
file_name_label = Label(root,
                        textvariable=file_name,
                        justify=LEFT,
                        wraplengt=250)
file_name_label.place(x=20, y=150)

connect_int = IntVar()
connect_check = Checkbutton(root,
                            text=u"connect to unity\n(port 5067)",
示例#31
0
class Toplevel1:
    date = datetime.date.today()

    def getClientAlgoList(self):
        client_list = []
        algo_list = []

        connection = MongoClient('localhost', 27017)
        listdb = connection['all_list']
        collection_client = listdb['client']
        collection_algo = listdb['algo']
        for i in collection_client.distinct("client"):
            client_list.append(i)
        for i in collection_algo.distinct("value"):
            algo_list.append(i)
        return client_list, algo_list

    def squareoff(self):
        collec = f'cumulative_{self.date}'
        strategyName = self.var_strategy.get()
        clientID = self.var_client.get()
        try:
            connection = MongoClient('localhost', 27017)
            cumulative_db = connection.Cumulative_symphonyorder
            cumulative_collection = cumulative_db[collec]
        except:
            messagebox.showerror("Database Connection Error",
                                 "Could not connect to database. Please check your connection.")

        if strategyName == "All" and clientID == "All":
            print(strategyName, "========", clientID)
            documents = cumulative_collection.find()
        elif strategyName == "All":
            print(strategyName, "========", clientID)
            documents = cumulative_collection.find({'clientID': clientID})
        elif clientID == "All":
            print(strategyName, "========", clientID)
            documents = cumulative_collection.find({'algoName': strategyName})
        else:
            print(strategyName, "========", clientID)
            documents = cumulative_collection.find(
                {"$and": [{"algoName": strategyName}, {"clientID": clientID}]})

        # order = orderManagement.OrderSystem()
        # order = orderManagement.OrderSystem2()
        obj = orderSlicer.OrderSystem()
        for doc in documents:
            # print("DOCS=====",doc)
            exchangeSegment = doc["exchangeSegment"]
            exchangeInstrumentID = doc["exchangeInstrumentID"]
            productType = doc["productType"]
            orderType = 'MARKET'  # doc["orderType"]
            orderQuantity = doc["quantity"]
            if orderQuantity < 0:
                orderSide = "BUY"
            else:
                orderSide = "SELL"

            algoName = doc["algoName"]
            clientID = doc['clientID']
            symbol = doc["symbol"]
            try:
                with open(rf'C:\Users\Mudraksh_Server1\Desktop\ServerCodes\Symphony Order Server Dealer 2.0\Allowed algos\\{algoName}.txt') as file:
                    otp = file.read()
                    # print(otp)
            except Exception as e:
                pass
            if symbol.startswith("BANKNIFTY") and orderQuantity != 0:
                # if abs(orderQuantity) > 60:
                p1 = Process(target=obj.placeSliceOrder, args=(
                    exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide, abs(
                        orderQuantity), algoName,
                    clientID, 60,
                    0.1, otp)).start()
                # else:
                #     order.place_order(exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide,
                #                       abs(orderQuantity), algoName, clientID)
            elif symbol.startswith("NIFTY") and orderQuantity != 0:
                # if abs(orderQuantity) > 225:
                p1 = Process(target=obj.placeSliceOrder, args=(
                    exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide, abs(
                        orderQuantity), algoName,
                    clientID, 225,
                    0.2, otp)).start()
                # else:
                #     order.place_order(exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide,
                #                       abs(orderQuantity), algoName, clientID)
            # elif orderQuantity != 0:
            #     order.place_order(exchangeSegment, exchangeInstrumentID, productType,
            #                       orderType, orderSide, abs(orderQuantity), algoName, clientID)
            # if orderQuantity != 0:
            #     order.place_order(exchangeSegment,exchangeInstrumentID,productType,orderType,orderSide,orderQuantity,algoName,clientID)
            # ,exchangeSegment,exchangeInstrumentID,
                # 	   productType,orderType,orderSide,orderQuantity, algoName
        messagebox.showinfo("Success", "SquareOff Successfull.")
        # messagebox.showinfo("Hey Hey","Its squareoff function.")

    def squareoff_all(self):
        collec = f'cumulative_{self.date}'

        try:
            connection = MongoClient('localhost', 27017)
            cumulative_db = connection.Cumulative_symphonyorder
            cumulative_collection = cumulative_db[collec]
        except:
            messagebox.showerror("Database Connection Error",
                                 "Could not connect to database. Please check your connection.")

        documents = cumulative_collection.find()
        # order = orderManagement.OrderSystem()
        # order = orderManagement.OrderSystem2()
        obj = orderSlicer.OrderSystem()
        for doc in documents:
            if doc['algoName'] != '1000 EMA Overnight':
                exchangeSegment = doc["exchangeSegment"]
                exchangeInstrumentID = doc["exchangeInstrumentID"]
                productType = doc["productType"]
                orderType = 'MARKET'  # doc["orderType"]

                orderQuantity = doc["quantity"]
                if orderQuantity < 0:
                    orderSide = "BUY"
                else:
                    orderSide = "SELL"

                algoName = doc["algoName"]
                clientID = doc["clientID"]
                symbol = doc["symbol"]
                print("SYMBOL ======", symbol)

                try:
                    with open(rf'C:\Users\Mudraksh_Server1\Desktop\ServerCodes\Symphony Order Server Dealer 2.0\Allowed algos\\{algoName}.txt') as file:
                        otp = file.read()
                        # print(otp)
                except Exception as e:
                    pass

                if symbol.startswith("BANKNIFTY") and orderQuantity != 0:
                    print("HEY BANK")
                    # if abs(orderQuantity) > 60:
                    p1 = Process(target=obj.placeSliceOrder, args=(
                        exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide, abs(
                            orderQuantity), algoName,
                        clientID, 60,
                        0.1, otp)).start()
                    # else:
                    #     order.place_order(exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide,
                    #                       abs(orderQuantity), algoName, clientID)

                elif symbol.startswith("NIFTY") and orderQuantity != 0:
                    print("HEY NIF")
                    # if abs(orderQuantity) > 225:
                    p1 = Process(target=obj.placeSliceOrder, args=(
                        exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide, abs(
                            orderQuantity), algoName,
                        clientID, 225,
                        0.2, otp)).start()
                # else:
                #     order.place_order(exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide,
                #                       abs(orderQuantity), algoName, clientID)
            # elif orderQuantity != 0:
            #     print("HEY OTHER")
            #     order.place_order(exchangeSegment, exchangeInstrumentID, productType, orderType, orderSide,
            #                       abs(orderQuantity), algoName, clientID)

            # if orderQuantity != 0:
            #     order.place_order(exchangeSegment,exchangeInstrumentID,productType,orderType,orderSide,abs(orderQuantity),algoName,clientID)
            # ,exchangeSegment,exchangeInstrumentID,
                # 	   productType,orderType,orderSide,orderQuantity, algoName
        messagebox.showinfo("Success", "SquareOff Successfull.")

    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font11 = "-family {Yu Gothic UI Semibold} -size 14 -weight "  \
            "bold -slant roman -underline 0 -overstrike 0"
        font12 = "-family {Segoe UI} -size 12 -weight normal -slant "  \
            "roman -underline 0 -overstrike 0"
        font13 = "-family {Segoe UI} -size 9 -weight bold -slant roman"  \
            " -underline 0 -overstrike 0"

        top.geometry("600x450+342+53")
        top.minsize(120, 1)
        top.maxsize(1370, 749)
        top.resizable(1, 1)
        top.title("Auto Square Off")
        top.configure(background="#d9d9d9")

        self.Frame1 = tk.Frame(top)
        self.Frame1.place(relx=0.05, rely=0.067,
                          relheight=0.878, relwidth=0.908)

        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.Frame1.configure(background="#d9d9d9")

        self.Button1 = tk.Button(self.Frame1)
        self.Button1.place(relx=0.44, rely=0.076, height=64, width=267)
        self.Button1.configure(activebackground="#ececec")
        self.Button1.configure(activeforeground="#000000")
        self.Button1.configure(background="#ff0000")
        self.Button1.configure(cursor="fleur")
        self.Button1.configure(disabledforeground="#a3a3a3")
        self.Button1.configure(font=font11)
        self.Button1.configure(foreground="#000000")
        self.Button1.configure(highlightbackground="#d9d9d9")
        self.Button1.configure(highlightcolor="black")
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''SquareOff All''')
        self.Button1.configure(command=self.squareoff_all)

        self.Frame2 = tk.Frame(self.Frame1)
        self.Frame2.place(relx=0.055, rely=0.38,
                          relheight=0.494, relwidth=0.89)
        self.Frame2.configure(relief='groove')
        self.Frame2.configure(borderwidth="2")
        self.Frame2.configure(relief="groove")
        self.Frame2.configure(background="#d9d9d9")

        self.Label1 = tk.Label(self.Frame2)
        self.Label1.place(relx=0.082, rely=0.103, height=27, width=150)
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font=font12)
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(text='''Strategy Name''')

        self.var_strategy = StringVar(self.Frame2)
        self.var_strategy.set("All")  # initial value

        client_list, strategy_list = self.getClientAlgoList()

        self.textstrategy = OptionMenu(
            self.Frame2, self.var_strategy, *strategy_list)
        # self.textalgoname.place(relx=0.142, rely=0.05, x=-2, y=2)
        self.textstrategy.place(relx=0.082, rely=0.43, height=24, width=200)
        # print(var_strategy)

        self.Label2 = tk.Label(self.Frame2)
        self.Label2.place(relx=0.68, rely=0.103, height=27, width=100)
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font=font12)
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(text='''ClientID''')

        self.var_client = StringVar(self.Frame2)
        self.var_client.set("All")  # initial value

        self.textclient = OptionMenu(
            self.Frame2, self.var_client, *client_list)
        # self.textalgoname.place(relx=0.142, rely=0.05, x=-2, y=2)
        self.textclient.place(relx=0.68, rely=0.43, height=24, width=150)

        self.Button2 = tk.Button(self.Frame2)
        self.Button2.place(relx=0.412, rely=0.667, height=44, width=87)
        self.Button2.configure(activebackground="#ececec")
        self.Button2.configure(activeforeground="#000000")
        self.Button2.configure(background="#0080c0")
        self.Button2.configure(disabledforeground="#a3a3a3")
        self.Button2.configure(font=font13)
        self.Button2.configure(foreground="#000000")
        self.Button2.configure(highlightbackground="#d9d9d9")
        self.Button2.configure(highlightcolor="black")
        self.Button2.configure(pady="0")
        self.Button2.configure(text='''SquareOff''')
        self.Button2.configure(command=self.squareoff)