def init_gui(self): "Build the GUI." self.root.title('Gas Property Calculator') self.grid(column=0, row=0, sticky='nsew') # Initialize Variables self.initial_type = None self.final_type = None # Mixture creation species = [] species_vals = [] num_species = 9 # Number of species to include for i in range(num_species): # Create species buttons specie = tkinter.StringVar() spec = ttk.Entry(self, width=10, textvariable=specie) spec.grid(column=0, row=i+1) val = tkinter.DoubleVar() vals = ttk.Entry(self, width=12, textvariable=val) vals.grid(column=1, row=i+1) species.append(specie) species_vals.append(val) self.species = species self.species_vals = species_vals int_row = i + 1 # Intermediate row self.phi = tkinter.StringVar() self.phi_entry = ttk.Entry(self, width=10, textvariable=self.phi) self.phi_entry.grid(column=1, row=int_row+1) self.phi.trace('w', self.change_phi) # Run when value changes ttk.Label(self, text='Equivalence Ratio').grid(column=0, row=int_row+1) ttk.Label(self, text='Species').grid(column=0, row=0) ttk.Label(self, text='Relative Moles').grid(column=1, row=0) # Separator ttk.Separator(self, orient='horizontal').grid(column=0, row=int_row+2, columnspan=7, sticky='ew') int_row += 3 # Move reference row down a bit # Initial / Calculated Conditions self.T = tkinter.StringVar() self.P = tkinter.StringVar() self.H = tkinter.StringVar() self.S = tkinter.StringVar() self.D = tkinter.StringVar() self.U = tkinter.StringVar() self.T_entry = ttk.Entry(self, width=12, textvariable=self.T) self.P_entry = ttk.Entry(self, width=12, textvariable=self.P) self.H_entry = ttk.Entry(self, width=12, textvariable=self.H) self.S_entry = ttk.Entry(self, width=12, textvariable=self.S) self.D_entry = ttk.Entry(self, width=12, textvariable=self.D) self.U_entry = ttk.Entry(self, width=12, textvariable=self.U) self.initial_entries = [self.T_entry, self.P_entry, self.H_entry, self.S_entry, self.D_entry, self.U_entry] self.T_entry.grid(column=0, row=int_row+1) self.P_entry.grid(column=0, row=int_row+2) self.H_entry.grid(column=0, row=int_row+3) self.S_entry.grid(column=0, row=int_row+4) self.D_entry.grid(column=0, row=int_row+5) self.U_entry.grid(column=0, row=int_row+6) ttk.Label(self, text='Initial Conditions').grid(column=0, row=int_row) self.initial_button = ttk.Button( self, text='Calc. Initial Conditions', command=self.calculate_initial) self.initial_button.grid(column=0, row=int_row+7) # Final Conditions ttk.Separator(self, orient='vertical').grid(column=3, row=0, rowspan=25, sticky='ns') self.T_f = tkinter.StringVar() self.P_f = tkinter.StringVar() self.H_f = tkinter.StringVar() self.S_f = tkinter.StringVar() self.D_f = tkinter.StringVar() self.U_f = tkinter.StringVar() self.T_f_entry = ttk.Entry(self, width=12, textvariable=self.T_f) self.P_f_entry = ttk.Entry(self, width=12, textvariable=self.P_f) self.H_f_entry = ttk.Entry(self, width=12, textvariable=self.H_f) self.S_f_entry = ttk.Entry(self, width=12, textvariable=self.S_f) self.D_f_entry = ttk.Entry(self, width=12, textvariable=self.D_f) self.U_f_entry = ttk.Entry(self, width=12, textvariable=self.U_f) self.final_entries = [self.T_f_entry, self.P_f_entry, self.H_f_entry, self.S_f_entry, self.D_f_entry, self.U_f_entry] self.T_f_entry.grid(column=2, row=int_row+1) self.P_f_entry.grid(column=2, row=int_row+2) self.H_f_entry.grid(column=2, row=int_row+3) self.S_f_entry.grid(column=2, row=int_row+4) self.D_f_entry.grid(column=2, row=int_row+5) self.U_f_entry.grid(column=2, row=int_row+6) ttk.Label(self, text='Final Conditions').grid(column=2, row=int_row) ttk.Label(self, text='Temperature (K)').grid(column=1, row=int_row+1) ttk.Label(self, text='Pressure (Pa)').grid(column=1, row=int_row+2) ttk.Label(self, text='Enthalpy (J/kg)').grid(column=1, row=int_row+3) ttk.Label(self, text='Entropy (J/kg/K)').grid(column=1, row=int_row+4) ttk.Label(self, text='Density (kg/m^3)').grid(column=1, row=int_row+5) ttk.Label(self, text='Energy (J/kg)').grid(column=1, row=int_row+6) self.final_button = ttk.Button( self, text='Calc. Final Conditions', command=self.calculate_final) self.final_button.grid(column=2, row=int_row+7) # Menu bar self.root.option_add('*tearOff', 'FALSE') self.menubar = tkinter.Menu(self.root) self.menu_file = tkinter.Menu(self.menubar) self.menu_file.add_command(label='Exit', command=self.on_quit) self.menu_file.add_command(label='Open Chem. File', command=self.openf) self.menu_edit = tkinter.Menu(self.menubar) self.menubar.add_cascade(menu=self.menu_file, label='File') self.root.config(menu=self.menubar) # Problem type radio buttons ttk.Label(self, text='Problem Type').grid(column=4, row=0) self.problem_type = tkinter.IntVar() ttk.Radiobutton(self, text='Chemically Frozen', variable=self.problem_type, value=0, command=self.change_ptype).grid(column=4, row=1) ttk.Radiobutton(self, text='Isentropic Compression. cr:', variable=self.problem_type, value=1, command=self.change_ptype).grid(column=4, row=2) ttk.Radiobutton(self, text='Chemical Equilibrium', variable=self.problem_type, value=2, command=self.change_ptype).grid(column=4, row=3) self.cr = tkinter.StringVar() self.cr_Entry = ttk.Entry(self, width=5, textvariable=self.cr) self.cr_Entry.grid(column=5, row=2) self.cr.trace('w', self.change_cr) self.final_type_int = tkinter.IntVar() self.finaltype_buttons = [ ttk.Radiobutton(self, text='TP', variable=self.final_type_int, command=self.change_ftype, value=0), ttk.Radiobutton(self, text='HP', variable=self.final_type_int, command=self.change_ftype, value=1), ttk.Radiobutton(self, text='SP', variable=self.final_type_int, command=self.change_ftype, value=2), ttk.Radiobutton(self, text='SD', variable=self.final_type_int, command=self.change_ftype, value=3), ttk.Radiobutton(self, text='UV', variable=self.final_type_int, command=self.change_ftype, value=4), ttk.Radiobutton(self, text='Manual', variable=self.final_type_int, command=self.change_ftype, value=5) ] count = 5 for button in self.finaltype_buttons: button.grid(column=4, row=count) # button.state(statespec=['disabled']) count += 1 #print # Calculated mixture properties self.calc_labels = ['Cp (J/kg/K)', 'Cv (J/kg/K', 'gamma', 'Gibbs (J/kg)', 'MW (kg/kmol)', 'IsoT compressibility (1/Pa)', 'Therm. expansion coeff (1/K)'] self.calc_calls = ['cp', 'cv', 'GAMMA', 'g', 'mean_molecular_weight', 'isothermal_compressibility', 'thermal_expansion_coeff'] i = int_row+8 initials = [] finals = [] for label in self.calc_labels: init = tkinter.StringVar() final = tkinter.StringVar() ttk.Entry(self, width=12, textvariable=init, state='readonly').grid(column=0, row=i) ttk.Entry(self, width=12, textvariable=final, state='readonly').grid(column=2, row=i) ttk.Label(self, text=label).grid(column=1, row=i) i += 1 initials.append(init) finals.append(final) self.initial_calc = initials self.final_calc = finals # Final Composition ttk.Label(self, text='Final Composition').grid(column=4, row=int_row, columnspan=2) ttk.Label(self, text='Species').grid(column=4, row=int_row+1) ttk.Label(self, text='Mole Fraction').grid(column=5, row=int_row+1) final_spec = [] final_mole_frac = [] for ind in range(int_row+2, int_row+15): spec = tkinter.StringVar() val = tkinter.StringVar() ttk.Entry(self, width=10, textvariable=spec, state='readonly').grid(column=4, row=ind) ttk.Entry(self, width=12, textvariable=val, state='readonly').grid(column=5, row=ind) final_spec.append(spec) final_mole_frac.append(val) self.final_spec = final_spec self.final_mole_frac = final_mole_frac # Initialize chemistry file to therm.cti self.chemfile = os.path.join(sys.path[0], 'therm.cti')
def __init__(self, master): self.master = master self.master.title("Nagrody za kody") self.master.geometry('700x500') self.frame1 = tk.Frame(master) self.frame1.pack(fill='both', expand=True) self.button_import = tk.Button(self.frame1, text="Import plików Excel", command=lambda: self.file_choose()) self.button_import.pack() self.button_save = tk.Button( self.frame1, text="Podaj lokalizację zapisu", command=lambda: self.choose_save_location()) self.button_save.pack() self.label_file_count = tk.Label(self.frame1) self.label_file_count.pack() self.var_win = tk.IntVar() self.checkbox_win = tk.Checkbutton( self.frame1, text="Sprawdzaj max/min dla PPE", variable=self.var_win, command=lambda: self.label_state(self.var_win.get())) self.checkbox_win.pack(anchor="e") self.win_count = tk.StringVar() self.win_entry = tk.Entry(self.frame1, textvariable=self.win_count, state="disabled") self.win_entry.pack(anchor="e") self.var_SE = tk.IntVar() self.checkbox_SE = tk.Checkbutton( self.frame1, text="Nie uwzględniaj sprzedawców kompleksowych", variable=self.var_SE) self.checkbox_SE.pack(anchor="e") self.var1 = tk.IntVar() self.checkbox_1 = tk.Checkbutton(self.frame1, text="Dane pewne - kolor zielony", variable=self.var1) self.checkbox_1.pack(anchor="w") self.var2 = tk.IntVar() self.checkbox_2 = tk.Checkbutton(self.frame1, text="Dane niepewne - kolor czerwony", variable=self.var2) self.checkbox_2.pack(anchor="w") self.var3 = tk.IntVar() self.checkbox_3 = tk.Checkbutton( self.frame1, text="Dane prognozowane - kolor niebieski", variable=self.var3) self.checkbox_3.pack(anchor="w") self.var4 = tk.IntVar() self.checkbox_4 = tk.Checkbutton(self.frame1, text="Dane ręczne - kolor różowy", variable=self.var4) self.checkbox_4.pack(anchor="w") self.var5 = tk.IntVar() self.checkbox_5 = tk.Checkbutton( self.frame1, text="Braki schematów - kolor turkusowy", variable=self.var5) self.checkbox_5.pack(anchor="w") self.var6 = tk.IntVar() self.checkbox_6 = tk.Checkbutton(self.frame1, text="Braki danych - kolor szary", variable=self.var6) self.checkbox_6.pack(anchor="w") self.var7 = tk.IntVar() self.checkbox_7 = tk.Checkbutton(self.frame1, text="Zamknięta umowa - kolor biały", variable=self.var7) self.checkbox_7.pack(anchor="w") self.start_button = tk.Button( self.frame1, text="Start", command=lambda: self.start(imported_files, location, self. progress_var)) self.start_button.pack(anchor="s") self.progress_var = tk.DoubleVar() self.label_progress_var = tk.StringVar()
def test_listvariable(self): widget = self.create() var = tkinter.DoubleVar(self.root) self.checkVariableParam(widget, 'listvariable', var)
# PWM 객체 생성 : 11번 핀, 주파수 - 100Hz p_r = GPIO.PWM(LED_R, 100) p_y = GPIO.PWM(LED_Y, 100) p_g = GPIO.PWM(LED_G, 100) # PWM 신호 출력 p_r.start(0) p_y.start(0) p_g.start(0) # window Obj window = tk.Tk() window.geometry('300x300') # 변수 설정 led_r_value = tk.DoubleVar() led_y_value = tk.DoubleVar() led_g_value = tk.DoubleVar() led_r_value.set(0) led_y_value.set(0) led_g_value.set(0) # duty 값을 변경 함수 def change_duty_r(dc): p_r.ChangeDutyCycle(led_r_value.get()) def change_duty_y(dc): p_y.ChangeDutyCycle(led_y_value.get())
# Pin number label account_number_label = tk.Label(win, text="Account Number", width=30) # The pin number entry and associated variable. # Note: Modify this to 'show' PIN numbers as asterisks (i.e. **** not 1234) pin_number_var = tk.StringVar() pin_number_var.set("7890") account_pin_entry = tk.Entry(win, text='PIN Number', show="*", textvariable=pin_number_var, state=DISABLED) # The balance label and associated variable balance_var = tk.StringVar() balance_var.set('Balance: $0.00') balance_label = tk.Label(win, text="Balance: $0.00", width=20) # The Entry widget to accept a numerical value to deposit or withdraw amount_entry_var = tk.DoubleVar() amount_entry = tk.Entry(win, textvariable=amount_entry_var) # The transaction text widget holds text of the accounts transactions transaction_text_widget = tk.Text(win, height=10, width=48) # The bank account object we will work with account = BankAccount() # ---------- Button Handlers for Login Screen ---------- def clear_pin_entry(event): """Function to clear the PIN number entry when the Clear / Cancel button is clicked.""" # Clear the pin number entry here
#----------------------需要設定的參數---------------------------------------------- #檔名參數 file_name = tk.StringVar() file_name.set('ANN_training_data_AC_combination_1129') #輸入特徵參數 features_Num = tk.IntVar() features_Num.set(8) #輸入訓練次數 iteration = tk.IntVar() iteration.set(20000) #輸入隱藏層特徵數 hiddenlayer_features = tk.IntVar() hiddenlayer_features.set(5) #輸入學習速率 learning_rate = tk.DoubleVar() learning_rate.set(0.3) #學習狀況記錄 lossbuck_train = [] lossbuck_test = [] #----------------------需要設定的參數------------------------------------------------ def Tranning_by_Neural_Network(): #---------------------ANN前數據讀檔處理--------------------------------------------- #讀檔創建Dataframe #filepath='C:\\Users\\richard.weng\\Documents\\Python Scripts\\python_projects\\(1) NIVG Project\\ANN\\' file_data = file_name.get() + '.csv' df0 = pd.read_csv(file_data)
parser = argparse.ArgumentParser() parser.add_argument("--game", "-g", type=str) args = parser.parse_args() # Setup game environment and GUI env = Environment(args.game) gui = GUI(env.game_name(), env.n_channels) # Thread safe variables for use with GUI action = Tk.IntVar() action.set(0) action_taken = Tk.BooleanVar() action_taken.set(False) action_released = Tk.BooleanVar() action_released.set(False) G = Tk.DoubleVar() G.set(0.0) is_terminate = Tk.BooleanVar() is_terminate.set(False) # Map input keys to agent actions key_action_map = {' ': 5, 'left': 1, 'up': 2, 'right': 3, 'down': 4} # Key press handler for human player def on_key_event(event): if event.key == 'q': # quit the game gui.quit() elif (event.key == 'r'): # reset the game environment env.reset() elif (event.key in key_action_map):
def __init__(self, master, app=None): super(CreateFatigueWindow, self).__init__() if __name__ == '__main__': self._initial_structure_obj = test.get_structure_object() self.load_objects = [ test.get_loa_fls_load(), test.get_loa_uls_load(), test.get_bal_fls_load(), test.get_bal_uls_load() ] self.active_line = 'line1' points = test.line_dict['line1'] coords = (test.point_dict['point' + str(points[0])], test.point_dict['point' + str(points[1])]) self.pressure_coords = self.get_pressure_point_coord_from_two_points( coords[0], coords[1]) self.comp_objects = [test.get_tank_object()] self._initial_fatigue_obj = test.get_fatigue_object() else: if app._line_to_struc[app._active_line][0] is None: return elif app._line_to_struc[app._active_line][0].Stiffener is None: return self.app = app self.active_line = app._active_line points = app._line_dict[self.active_line] coords = (app._point_dict['point' + str(points[0])], app._point_dict['point' + str(points[1])]) self.pressure_coords = self.get_pressure_point_coord_from_two_points( coords[0], coords[1]) self._initial_structure_obj = app._line_to_struc[ app._active_line][0].Stiffener self.load_objects = app._line_to_struc[app._active_line][3] self.comp_objects = [ app._tank_dict['comp' + str(comp_i)] for comp_i in app.get_compartments_for_line(app._active_line) ] self._initial_fatigue_obj = app._line_to_struc[self.active_line][2] self._frame = master self._frame.wm_title("Specify fatigue properties here.") self._frame.geometry('1300x810') self._frame.grab_set() tk.Label( self._frame, text='-- Fatigue calculation for plates according to DNVGL-RP-C203, ' 'Section 5 Simplified fatigue analysis --', font='Verdana 15 bold').place(x=10, y=10) ent_w = 10 self.new_sn_curve = tk.StringVar() self.new_k_factor = tk.DoubleVar() self.new_no_of_cycles = tk.DoubleVar() self.new_design_life = tk.DoubleVar() self.new_dff = tk.DoubleVar() self.new_weibull_loa = tk.DoubleVar() self.new_weibull_bal = tk.DoubleVar() self.new_weibull_prt = tk.DoubleVar() self.new_period_loa = tk.DoubleVar() self.new_period_bal = tk.DoubleVar() self.new_period_prt = tk.DoubleVar() self.new_corr_loc_loa = tk.DoubleVar() self.new_corr_loc_bal = tk.DoubleVar() self.new_corr_loc_prt = tk.DoubleVar() self.new_fraction_loa = tk.DoubleVar() self.new_fraction_bal = tk.DoubleVar() self.new_fraction_prt = tk.DoubleVar() self.new_az_loa = tk.DoubleVar() self.new_az_bal = tk.DoubleVar() self.new_az_prt = tk.DoubleVar() sn_curves = sn.get_all_curves() self.ent_sn_curve = tk.OptionMenu(self._frame, self.new_sn_curve, command=self.change_sn_curve, *sn_curves) self.ent_dff = tk.Entry(self._frame, textvariable=self.new_dff, width=ent_w) self.ent_k_factor = tk.Entry(self._frame, textvariable=self.new_k_factor, width=ent_w) self.ent_no_of_cycles = tk.Entry(self._frame, textvariable=self.new_no_of_cycles, width=ent_w) self.ent_new_design_life = tk.Entry(self._frame, textvariable=self.new_design_life, width=ent_w) self.ent_weibull_loa = tk.Entry(self._frame, textvariable=self.new_weibull_loa, width=ent_w) self.ent_weibull_bal = tk.Entry(self._frame, textvariable=self.new_weibull_bal, width=ent_w) self.ent_weibull_prt = tk.Entry(self._frame, textvariable=self.new_weibull_prt, width=ent_w) self.ent_period_loa = tk.Entry(self._frame, textvariable=self.new_period_loa, width=ent_w) self.ent_period_bal = tk.Entry(self._frame, textvariable=self.new_period_bal, width=ent_w) self.ent_period_prt = tk.Entry(self._frame, textvariable=self.new_period_prt, width=ent_w) self.ent_corr_loc_loa = tk.Entry(self._frame, textvariable=self.new_corr_loc_loa, width=ent_w) self.ent_corr_loc_bal = tk.Entry(self._frame, textvariable=self.new_corr_loc_bal, width=ent_w) self.ent_corr_loc_prt = tk.Entry(self._frame, textvariable=self.new_corr_loc_prt, width=ent_w) self.ent_fraction_loa = tk.Entry(self._frame, textvariable=self.new_fraction_loa, width=ent_w) self.ent_fraction_bal = tk.Entry(self._frame, textvariable=self.new_fraction_bal, width=ent_w) self.ent_fraction_prt = tk.Entry(self._frame, textvariable=self.new_fraction_prt, width=ent_w) self.ent_acc_loa = tk.Entry(self._frame, textvariable=self.new_az_loa, width=ent_w) self.ent_acc_bal = tk.Entry(self._frame, textvariable=self.new_az_bal, width=ent_w) self.ent_acc_prt = tk.Entry(self._frame, textvariable=self.new_az_prt, width=ent_w) start_x, start_y, dx, dy = 20, 100, 150, 35 loaded_exist = False ballast_exist = False part_exist = False fls_exist = (loaded_exist, ballast_exist, part_exist) # Frames to hide loaded, ballast or part loa_fr = tk.Frame(self._frame, width=100, height=170, bg="gray25", colormap="new") bal_fr = tk.Frame(self._frame, width=100, height=170, bg="gray25", colormap="new") prt_fr = tk.Frame(self._frame, width=100, height=170, bg="gray25", colormap="new") for load in self.load_objects: if load != None: if load.get_limit_state() == 'FLS': if load.get_load_condition() == 'loaded': loaded_exist = True elif load.get_load_condition() == 'ballast': ballast_exist = True elif load.get_load_condition() == 'part': part_exist = True else: pass fls_exist = (loaded_exist, ballast_exist, part_exist) if self._initial_fatigue_obj == None: self.new_sn_curve.set('Ec') self.new_k_factor.set(1) self.new_no_of_cycles.set(10000) self.new_design_life.set(20) self.new_dff.set(2) if any(fls_exist): if loaded_exist: self.new_fraction_loa.set(1 / fls_exist.count(True)) self.new_weibull_loa.set(0.8) self.new_period_loa.set(8) self.new_corr_loc_loa.set(0.5) self.new_az_loa.set(0.5) if ballast_exist: self.new_fraction_bal.set(1 / fls_exist.count(True)) self.new_weibull_bal.set(0.8) self.new_period_bal.set(8) self.new_corr_loc_bal.set(0.5) self.new_az_bal.set(0.5) if part_exist: self.new_fraction_prt.set(1 / fls_exist.count(True)) self.new_weibull_prt.set(0.8) self.new_period_prt.set(8) self.new_corr_loc_prt.set(0.5) self.new_az_prt.set(0.5) else: fat_prop = self._initial_fatigue_obj.get_fatigue_properties() self.new_sn_curve.set(fat_prop['SN-curve']) self.new_k_factor.set(fat_prop['SCF']) self.new_no_of_cycles.set(fat_prop['n0']) self.new_design_life.set(fat_prop['Design life']) self.new_dff.set(fat_prop['DFF']) if any(fls_exist): if loaded_exist: self.new_fraction_loa.set(fat_prop['Fraction'][0]) self.new_weibull_loa.set(fat_prop['Weibull'][0]) self.new_period_loa.set(fat_prop['Period'][0]) self.new_corr_loc_loa.set(fat_prop['CorrLoc'][0]) self.new_az_loa.set(fat_prop['Accelerations'][0]) if ballast_exist: self.new_fraction_bal.set(fat_prop['Fraction'][1]) self.new_weibull_bal.set(fat_prop['Weibull'][1]) self.new_period_bal.set(fat_prop['Period'][1]) self.new_corr_loc_bal.set(fat_prop['CorrLoc'][1]) self.new_az_bal.set(fat_prop['Accelerations'][1]) if part_exist: self.new_fraction_prt.set(fat_prop['Fraction'][2]) self.new_weibull_prt.set(fat_prop['Weibull'][2]) self.new_period_prt.set(fat_prop['Period'][2]) self.new_corr_loc_prt.set(fat_prop['CorrLoc'][2]) self.new_az_prt.set(fat_prop['Accelerations'][2]) all_acc = (self.new_az_loa.get(), self.new_az_bal.get(), self.new_az_prt.get()) count = 1 for load in self.load_objects: if load == None: continue press = [] if load.get_limit_state() == 'FLS': tk.Label(self._frame, text=str(count)+'. '+load.get_name(), font='Verdana 8')\ .place(x=start_x + 5 * dx, y=start_y + (5+count) * dy) idx = 0 for exist in fls_exist: if exist: press.append( round( load.get_calculated_pressure( self.pressure_coords, all_acc[idx], self._initial_structure_obj. get_structure_type()), 1)) idx += 1 tk.Label(self._frame, text=press, font='Verdana 8') \ .place(x=start_x + 6.5 * dx, y=start_y + (5 + count) * dy) count += 1 press = [] for comp in self.comp_objects: if comp == None: continue tk.Label(self._frame, text=str(count) + '. ' +str(comp.get_name()), font='Verdana 8') \ .place(x=start_x + 5 * dx, y=start_y + (5 + count) * dy) idx = 0 if fls_exist[0] and comp.is_loaded_condition(): press.append( round( comp.get_calculated_pressure(self.pressure_coords, all_acc[0]), 1)) if fls_exist[1] and comp.is_ballast_condition(): press.append( round( comp.get_calculated_pressure(self.pressure_coords, all_acc[1]), 1)) if fls_exist[2] and any( [comp.is_loaded_condition(), comp.is_ballast_condition()]): press.append( round( comp.get_calculated_pressure(self.pressure_coords, all_acc[2]), 1)) tk.Label(self._frame, text=press, font='Verdana 8') \ .place(x=start_x + 6.5 * dx, y=start_y + (5 + count) * dy) count += 1 tk.Label(self._frame, text='Design life:', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 0*dy) tk.Label(self._frame, text='Design Fatigue Factor (DFF):', font='Verdana 8 bold') \ .place(x=start_x+ 3*dx , y=start_y + 0*dy) tk.Label(self._frame, text='SN-curve:', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 1*dy) tk.Label(self._frame, text='Cycles in return period, n0', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 2*dy) tk.Label(self._frame, text='Stress Concentration Factor, SCF', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 3*dy) tk.Label(self._frame, text='Loaded', font='Verdana 8 bold') \ .place(x=start_x+2*dx , y=start_y + 5*dy) tk.Label(self._frame, text='Ballast', font='Verdana 8 bold') \ .place(x=start_x+3*dx , y=start_y + 5*dy) tk.Label(self._frame, text='Part', font='Verdana 8 bold') \ .place(x=start_x+4*dx , y=start_y + 5*dy) tk.Label(self._frame, text='Defined loads', font='Verdana 8 bold') \ .place(x=start_x+5*dx , y=start_y + 5*dy) tk.Label(self._frame, text='Resulting pressures', font='Verdana 8 bold') \ .place(x=start_x+6.5*dx , y=start_y + 5*dy) tk.Label(self._frame, text='Fraction (sum of bal/part/loa is 1)', font='Verdana 8 bold') \ .place(x=start_x, y=start_y + 6 * dy) tk.Label(self._frame, text='Weibull', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 7*dy) tk.Label(self._frame, text='Period', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 8*dy) tk.Label(self._frame, text='Corr. loc.', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 9*dy) tk.Label(self._frame, text='Accelerations', font='Verdana 8 bold') \ .place(x=start_x , y=start_y + 10*dy) self.ent_new_design_life.place(x=start_x + 2 * dx, y=start_y + 0 * dy) self.ent_dff.place(x=start_x + 5 * dx, y=start_y + 0 * dy) self.ent_sn_curve.place(x=start_x + 2 * dx, y=start_y + 1 * dy) self.ent_no_of_cycles.place(x=start_x + 2 * dx, y=start_y + 2 * dy) self.ent_k_factor.place(x=start_x + 2 * dx, y=start_y + 3 * dy) self.ent_fraction_loa.place(x=start_x + 2 * dx, y=start_y + 6 * dy) self.ent_fraction_bal.place(x=start_x + 3 * dx, y=start_y + 6 * dy) self.ent_fraction_prt.place(x=start_x + 4 * dx, y=start_y + 6 * dy) self.ent_weibull_loa.place(x=start_x + 2 * dx, y=start_y + 7 * dy) self.ent_weibull_bal.place(x=start_x + 3 * dx, y=start_y + 7 * dy) self.ent_weibull_prt.place(x=start_x + 4 * dx, y=start_y + 7 * dy) self.ent_period_loa.place(x=start_x + 2 * dx, y=start_y + 8 * dy) self.ent_period_bal.place(x=start_x + 3 * dx, y=start_y + 8 * dy) self.ent_period_prt.place(x=start_x + 4 * dx, y=start_y + 8 * dy) self.ent_corr_loc_loa.place(x=start_x + 2 * dx, y=start_y + 9 * dy) self.ent_corr_loc_bal.place(x=start_x + 3 * dx, y=start_y + 9 * dy) self.ent_corr_loc_prt.place(x=start_x + 4 * dx, y=start_y + 9 * dy) self.ent_acc_loa.place(x=start_x + 2 * dx, y=start_y + 10 * dy) self.ent_acc_bal.place(x=start_x + 3 * dx, y=start_y + 10 * dy) self.ent_acc_prt.place(x=start_x + 4 * dx, y=start_y + 10 * dy) # if not loaded_exist: # loa_fr.place(x=start_x + 2 * dx, y=start_y + 6 * dy) # elif not ballast_exist: # bal_fr.place(x=start_x + 3 * dx, y=start_y + 6 * dy) # elif not part_exist: # prt_fr.place(x=start_x + 4 * dx, y=start_y + 6 * dy) self._close_and_save = tk.Button(self._frame, text='Return fatigue parameters', command=self.save_and_close, bg='green', font='Verdana 15', fg='yellow') self._close_and_save.place(x=start_x + dx, y=start_y + dy * 15)
def test_configure_variable(self): widget = self.create() var = tkinter.DoubleVar(self.root) self.checkVariableParam(widget, 'variable', var)
def create_user_panel(self) -> object: self.x_label = tk.Label(text="X") self.x_label.grid(row=1, column=1) self.x_value = tk.DoubleVar() self.x_coor = tk.Entry(bd=5, textvariable=self.x_value) self.x_coor.grid(row=1, column=2) self.y_label = tk.Label(text="Y") self.y_label.grid(row=2, column=1) self.y_value = tk.DoubleVar() self.y_coor = tk.Entry(bd=5, textvariable=self.y_value) self.y_coor.grid(row=2, column=2) self.u_label = tk.Label(text="U") self.u_label.grid(row=1, column=3) self.u_value = tk.DoubleVar() self.u_coor = tk.Entry(bd=5, textvariable=self.u_value) self.u_coor.grid(row=1, column=4) self.v_label = tk.Label(text="V") self.v_label.grid(row=2, column=3) self.v_value = tk.DoubleVar() self.v_coor = tk.Entry(bd=5, textvariable=self.v_value) self.v_coor.grid(row=2, column=4) self.m_label = tk.Label(text="M") self.m_label.grid(row=3, column=1) self.m = tk.Scale(variable="weight", activebackground="red", orient="horizontal") self.m.grid(row=3, column=2) self.create_point = tk.Button(text="generate", command=self.CreateRandom) self.create_point.grid(row=3, column=3, columnspan=1) self.create_point = tk.Button(text="create", command=self.CreatePoint) self.create_point.grid(row=3, column=4, columnspan=1) #self.Verle_value = tk.IntVar() # self.Verle1 = tk.Radiobutton(text="Верле(Python)", variable=self.Verle_value, value=1, indicatoron=0) # self.Verle1.grid(row=4, column=1) # # self.Verle2 = tk.Radiobutton(text="Верле(odeint)", variable=self.Verle_value, value=2, indicatoron=0) # self.Verle2.grid(row=4, column=2) # # self.Verle3 = tk.Radiobutton(text="Верле(cython)",variable=self.Verle_value, value=3, indicatoron=0) # self.Verle3.grid(row=4, column=3) # # self.Verle4 = tk.Radiobutton(text="Верле(parallel)", variable=self.Verle_value, value=4, indicatoron=0) # self.Verle4.grid(row=4, column=4) # self.x_label = tk.Label(text="emitter_X") # self.x_label.grid(row=5, column=1) # self.x_coor = tk.Entry(bd=5) # self.x_coor.grid(row=5, column=2) # self.emitter_y_label = tk.Label(text="emitter_Y") # self.emitter_y_label.grid(row=5, column=3) # self.emitter_y_coor = tk.Entry(bd=5) # self.emitter_y_coor.grid(row=5, column=4) self.options = [ "Верле(Python)", "Odeint", "Верле(cython)", "Верле(parallel)" ] self.Verle_value = tk.StringVar() self.Verle_value.set("Верле(Python)") self.Verle = tk.OptionMenu(root, self.Verle_value, *self.options) self.Verle.grid(row=5, column=1) self.Verle.config(font=('calibri', (10)), bg='white', width=12) self.Verle['menu'].config(font=('calibri', (10)), bg='white') self.verle_step = tk.Button(text="play", command=self.Play) self.verle_step.grid(row=5, column=2) self.verle_step = tk.Button(text="verle step", command=self.NextStep) self.verle_step.grid(row=7, column=1) self.verle_step = tk.Button(text="calculate time", command=self.CalculateTime) self.verle_step.grid(row=7, column=2)
def __init__(self, root, master, *args, **kwargs): self.master = master self.root = root self.activation_function = "Symmetrical Hard limit" self.hebbian_rule = "Delta Rule" self.alpha = 0.1 self.nUnit = 10 self.t = -1 * np.ones((10,1000)) # self.t.fill(-1.0/9.0) self.p = np.ones((785, 1000), dtype=np.float32) self.training_input = np.zeros((785, 800)) self.training_target = np.zeros((10, 800)) self.testing_input = np.zeros((785, 200)) self.testing_target = np.zeros((10, 200)) self.load_input_vector() self.weight = np.zeros((10, 785)) #self.weight = (self.weight * 0.002) - 0.001 self.x = np.zeros(100) self.y = np.zeros(100) self.x_start = 0 ######################################################################### # Set up the constants and default values ######################################################################### self.xmin = 0 self.xmax = 1000 self.ymin = 0 self.ymax = 100 ######################################################################### # Set up the plotting area ######################################################################### self.plot_frame = tk.Frame(self.master) self.plot_frame.grid(row=0, column=0, columnspan=2, sticky=tk.N + tk.E + tk.S + tk.W) self.plot_frame.rowconfigure(0, weight=1) self.plot_frame.columnconfigure(0, weight=1) self.figure = plt.figure("") self.axes = self.figure.gca() self.axes.set_xlabel('Epoch') self.axes.set_ylabel('Error rate') self.axes.set_title("") plt.xlim(self.xmin, self.xmax) plt.ylim(self.ymin, self.ymax) self.canvas = FigureCanvasTkAgg(self.figure, master=self.plot_frame) self.plot_widget = self.canvas.get_tk_widget() self.plot_widget.grid(row=0, column=0, sticky=tk.N + tk.E + tk.S + tk.W) ######################################################################### # Set up the frame for sliders (scales) ######################################################################### self.sliders_frame = tk.Frame(self.master) self.sliders_frame.grid(row=1, column=0, sticky=tk.N + tk.E + tk.S + tk.W) self.sliders_frame.rowconfigure(0, weight=10) self.sliders_frame.rowconfigure(1, weight=2) self.sliders_frame.columnconfigure(0, weight=5, uniform='xx') self.sliders_frame.columnconfigure(1, weight=1, uniform='xx') # set up the sliders self.alpha_slider = tk.Scale(self.sliders_frame, variable=tk.DoubleVar(), orient=tk.HORIZONTAL, from_=0.001, to_=1.0, resolution=0.01, bg="#DDDDDD", activebackground="#FF0000", highlightcolor="#00FFFF", label="Alpha", command=lambda event: self.alpha_slider_callback()) self.alpha_slider.set(self.alpha) self.alpha_slider.bind("<ButtonRelease-1>", lambda event: self.alpha_slider_callback()) self.alpha_slider.grid(row=2, column=0, sticky=tk.N + tk.E + tk.S + tk.W) ######################################################################### # Set up the frame for button(s) ######################################################################### self.buttons_frame = tk.Frame(self.master) self.buttons_frame.grid(row=1, column=1, sticky=tk.N + tk.E + tk.S + tk.W) self.buttons_frame.rowconfigure(0, weight=1) self.buttons_frame.columnconfigure(0, weight=1, uniform='xx') self.label_for_hebbian_rule = tk.Label(self.buttons_frame, text="Select Learning Method", justify="center") self.label_for_hebbian_rule.grid(row=3, column=0, sticky=tk.N + tk.E + tk.S + tk.W) self.hebbian_rule_variable = tk.StringVar() self.hebbian_rule_dropdown = tk.OptionMenu(self.buttons_frame, self.hebbian_rule_variable, "Filtered Learning", "Delta Rule", "Unsupervised Hebb", command=lambda event: self.hebbian_rule_dropdown_callback()) self.hebbian_rule_variable.set("Delta Rule") self.hebbian_rule_dropdown.grid(row=4, column=0, sticky=tk.N + tk.E + tk.S + tk.W) self.label_for_activation_function = tk.Label(self.buttons_frame, text="Transfer Function", justify="center") self.label_for_activation_function.grid(row=5, column=0, sticky=tk.N + tk.E + tk.S + tk.W) self.activation_function_variable = tk.StringVar() self.activation_function_dropdown = tk.OptionMenu(self.buttons_frame, self.activation_function_variable, "Symmetrical Hard limit", "Hyperbolic Tangent", "Linear", command=lambda event: self.activation_function_dropdown_callback()) self.activation_function_variable.set("Hyperbolic Tangent") self.activation_function_dropdown.grid(row=6, column=0, sticky=tk.N + tk.E + tk.S + tk.W) self.draw_button = tk.Button(self.buttons_frame, text="Randomize Weights", fg="blue",width=16, command=self.randomize_weight) self.draw_button.grid(row=0, column=0) self.draw_button = tk.Button(self.buttons_frame, text="Adjust Weights (Learn)", fg="red",width=16, command=self.adjust_weight) self.draw_button.grid(row=1, column=0) print("Window size:", self.master.winfo_width(), self.master.winfo_height())
def __init__(self, master, trackapp=None, tokenlist=None, *args, **kwargs): super().__init__(master, *args, **kwargs) self.pack(side=tk.LEFT, expand=True, fill=tk.BOTH) self.trackapp = trackapp # app title version = "1.1.4a" self.master.title("Elevation Editor v." + version) new_tags = self.bindtags() + ("all", ) self.bindtags(new_tags) # token and brush data self._tokens = tuple() self._elevationProfiles = [] self._drag_data = {'x': 0, 'y': 0, 'items': [], 'feather': []} self._brush_data = { 'x': 0, 'r': tk.DoubleVar(value=10), 'f0': tk.DoubleVar(value=10), 'f1': tk.DoubleVar(value=10) } #r = brush radius, f = feather radius self._brushes = tuple() self._feathers = tuple() self._leftfeather = False self._rightfeather = False self._feathermode2 = [tk.StringVar(), tk.StringVar()] self._mouselabel = { "x_coord": 0, "y_coord": 0, 'x': tk.StringVar(), 'z': tk.StringVar() } self._mousepos = {'x': 0, 'y': 0} self._widgetsize = (None, None) self._past = [] self._future = [] # set offset, scales self._high_x = 0 self._high_y = 0 self._low_x = 0 self._low_y = 0 self._first_z = 0 self._brush_offset = self._high_x - self._low_x self._y_scale = -5.0 self._x_scale = 1.0 self._slopescale = -500 self.isLoop = 0 # set graphics self.line_width = 2 can_bg = "#6090CC" self.c_gridFill = "#4C74A4" gCan_bg = "#303030" self.g_gridFill = "#202020" self.tokenFill = "#FFFFFF" self.brushFill = "#5682B8" self.featherFill = "#5B89C2" ### MENUS ---------------------------------------------------------------------------------- # create a toplevel menu and a frame self.menubar = tk.Menu(self) #create pulldown file menu filemenu = tk.Menu(self.menubar, tearoff=0) filemenu.add_command(label="Load", command=self._load_ted) filemenu.add_command(label="Export", command=self._export_ted) filemenu.add_separator() #filemenu.add_command(label="Import elevation profile", command=self._import_ep) filemenu.add_command(label="Export elevation profile", command=self._export_ep) filemenu.add_separator() filemenu.add_command(label="Quit", command=self.quit) self.menubar.add_cascade(label="File", menu=filemenu) #create pulldown edit menu editmenu = tk.Menu(self.menubar, tearoff=0) editmenu.add_command(label="Undo", command=self._undo) editmenu.add_command(label="Redo", command=lambda: self._undo(arg="redo")) self.menubar.add_cascade(label="Edit", menu=editmenu) #create pulldown help menu helpmenu = tk.Menu(self.menubar, tearoff=0) helpmenu.add_command(label="Quick reference", command=self._quick_reference) self.menubar.add_cascade(label="Help", menu=helpmenu) #display the menu self.master.config(menu=self.menubar) #left panel self.leftPanel = dg.LeftPanel(self) ### CREATE CANVASES --------------------------------------------------------------------------- c_width = 600 # create a token canvas self.canvas = tk.Canvas(self, width=c_width, bg=can_bg, height=400, bd=1, relief="groove") new_tags = self.canvas.bindtags() + ("brusharea", "all") self.canvas.bindtags(new_tags) #create a graph canvas self.graphCanvas = tk.Canvas(self, width=c_width, bg=gCan_bg, height=200, bd=1, relief="groove") new_tags = self.graphCanvas.bindtags() + ("brusharea", "all") self.graphCanvas.bindtags(new_tags) # create the brush self._create_brush(self._brush_data['x']) ### SCROLLBARS --------------------------------------------------------------------------------- #add scrollbars self.hbar = tk.Scrollbar(self, orient="horizontal", command=self.xview) self.vbar = tk.Scrollbar(self, orient="vertical", command=self.yview) self.canvas.config(xscrollcommand=self.hbar.set, yscrollcommand=self.vbar.set) #add scalebar self.graphScaleBar = tk.Scrollbar(self, orient="vertical", command=self.graphScale) ### RULERS ----------------------------------------------------------------------------------- self.r_width = 50 #horizontal self.hruler = tk.Canvas(self, width=c_width, height=15, bd=1) #horizontal self.c_vruler = tk.Canvas(self, width=self.r_width, height=15, bd=1) #canvas self.g_vruler = tk.Canvas(self, width=self.r_width, height=15, bd=1) #graph ### BINDINGS ------------------------------------------------------------------------------------ self.bind_class("brusharea", "<ButtonPress-1>", self.OnTokenButtonPress) self.bind_class("brusharea", "<ButtonRelease-1>", self.OnTokenButtonRelease) self.bind_class("brusharea", "<B1-Motion>", self.OnTokenMotion) self.bind_class("brusharea", "<Shift-B1-Motion>", self.ShiftOnTokenMotion) self.bind_class("brusharea", "<Motion>", self.OnMotion) self.bind_class("brusharea", '<MouseWheel>', self.MouseWheel) self.bind_class("brusharea", '<Shift-MouseWheel>', self.ShiftMouseWheel) self.bind_class("brusharea", '<Control-MouseWheel>', self.ControlMouseWheel) self.bind_class("brusharea", '<Shift-Control-MouseWheel>', self.ShiftControlMouseWheel) self.bind_class("brusharea", '<ButtonPress-3>', self.Button3Press) self.bind_class("brusharea", '<B3-Motion>', self.MouseScroll) self.bind('f', self.FButtonPress) self.bind('s', self.SButtonPress) self.bind('z', self.zkey) self.bind('<Alt-z>', self.altzkey) self.bind('<Control-z>', self._undo) self.bind('<Control-y>', self._undo) self.bind('<Left>', self._leftkey) self.bind('<Right>', self._rightkey) self.bind('<Configure>', self._my_configure) self.bind('<Return>', self._returnkey) ### GEOMETRY MANAGEMENT --------------------------------------------------------------------- self.leftPanel.grid(row=0, column=0, rowspan=3, sticky="NS") self.canvas.grid(row=0, column=2, sticky="WENS") self.graphCanvas.grid(row=2, column=2, sticky="WE") self.hbar.grid(row=3, column=2, sticky="WE") self.vbar.grid(row=0, column=3, sticky="NS") self.graphScaleBar.grid(row=2, column=3, sticky="NS") self.hruler.grid(row=1, column=2, sticky="WE") self.c_vruler.grid(row=0, column=1, sticky="NS") self.g_vruler.grid(row=2, column=1, sticky="NS") self.columnconfigure(2, weight=1) self.rowconfigure(0, weight=1) ### OTHER --------------------------------------------------------------------------------- self.update_idletasks() self.focus_set()
"""A tour of ttk widgets we can use in our application""" import tkinter as tk from tkinter import ttk root = tk.Tk() my_string_var = tk.StringVar(value='Test') my_int_var = tk.IntVar() my_dbl_var = tk.DoubleVar() my_bool_var = tk.BooleanVar() pack_args = {"padx": 20, "pady": 20} def my_callback(*_): print("Callback called!") # Entry myentry = ttk.Entry(root, textvariable=my_string_var, width=20) myentry.pack(**pack_args) # Spinbox myspinbox = ttk.Spinbox(root, from_=0, to=100, increment=.01, textvariable=my_int_var, command=my_callback)
def __init__(self, master=None): """Application initialization """ tk.Frame.__init__(self, master) try: self.ser=serial.Serial('/dev/ttyUSB0', 9600, timeout=10, parity = serial.PARITY_NONE) #Keithley serial port - COM4: Deskotp, COM5: Laptop except: print("No serial port for keithley") try: self.ser1=serial.Serial('/dev/ttyACM0', 9600, timeout=10, parity = serial.PARITY_NONE) #Arduino serial port except: print("No serial port for arduino") self.fig = plt.Figure(figsize=(7, 6), dpi=100) self.fig.suptitle("I-V Sweep") self.a = self.fig.add_subplot(111) self.a.grid(b=True, which='major', color='r', linestyle='--') self.start = tk.DoubleVar() self.start.set(0.0) self.stop = tk.DoubleVar() self.stop.set(0.5) self.steps = tk.IntVar() self.steps.set(100) self.compliance = tk.DoubleVar() self.compliance.set(0.005) self.delay = tk.DoubleVar() self.delay.set(0.1) self.loops = tk.IntVar() self.loops.set(1) self.loopCount = tk.IntVar() self.loopCount.set(1) self.filenamenumber = tk.IntVar() self.filenamenumber.set(0) self.filename = tk.StringVar() self.filename.set("Sweep_") self.filenametext = tk.StringVar() self.setfilename() self.modes = tk.IntVar() self.modes.set(0) self.holdMode = tk.IntVar() self.holdMode.set(0) #Graph Variables self.XStart = tk.DoubleVar() self.XStart.set(0.0) self.XStop = tk.DoubleVar() self.XStop.set(0.5) self.YStop = tk.DoubleVar() self.YStop.set(0.005) self.YStart = tk.DoubleVar() self.YStart.set(-self.YStop.get()) self.mux = tk.IntVar() self.mux.set(0) self.quad0 = tk.BooleanVar() self.quad0.set(False) self.quad1 = tk.BooleanVar() self.quad1.set(False) self.quad2 = tk.BooleanVar() self.quad2.set(False) self.quad3 = tk.BooleanVar() self.quad3.set(False) self.columnconfigure(0, pad = 2) self.createWidgets() self.grid()
def __init__(self, from_master): sg.RaModuleGui.__init__(self, from_master) self.ww = 740 # window width self.wh = 900 # window height self.title = "Project Maker" self.set_geometry(self.ww, self.wh, self.title) self.condition_i_list = [] self.condition_p_list = [] self.condition_pl_list = [] self.condition_ter_list = [] self.condition_init = "" self.condition_proj = "" self.dir2prj = "" # os.path.dirname(os.path.abspath(__file__)) + "\\Geodata\\" self.dir2ap = config.dir2ml + "Output\\Rasters\\" self.fish = {} self.fish_applied = {} self.n = 0.04 self.txcr = 0.047 self.version = "" self.w_e = 14 # width of entries self.w_lb = 20 # width of listboxes self.xlsx_file_name = "" self.get_condition_lists() self.apply_wua = tk.BooleanVar() self.cover_app_pre = tk.BooleanVar() self.cover_app_post = tk.BooleanVar() self.prj_name = tk.StringVar() self.ter_cr = tk.DoubleVar() self.vege_cr = tk.DoubleVar() self.vege_stab_cr = tk.DoubleVar() self.complete_menus() # Create LABELS, ENTRIES and BUTTONS from LEFT to RIGHT and TOP-DOWN msg0 = "Welcome to the project maker GUI." msg1 = "Info - buttons help identifying requirements for running individual modules.\n\n" msg2 = "START: DEFINE AND VALIDATE VARIABLES\n" self.l_welcome = tk.Label(self, fg="white", background="gray45", text=msg0 + msg1 + msg2) self.l_welcome.grid(sticky=tk.EW, row=0, column=0, rowspan=2, columnspan=3, padx=self.xd, pady=self.yd) self.l_version = tk.Label(self, text="Project version: ") self.l_version.grid(sticky=tk.W, row=3, column=0, padx=self.xd, pady=self.yd) self.e_version = tk.Entry(self, width=self.w_e, textvariable=self.version) self.e_version.grid(sticky=tk.EW, row=3, column=1, padx=self.xd, pady=self.yd) self.l_version_help = tk.Label( self, fg="gray26", text="(3-digits: v+INT+INT, example: v10)") self.l_version_help.grid(sticky=tk.W, row=3, column=2, padx=self.xd, pady=self.yd) self.l_site_name = tk.Label(self, text="Project name: ") self.l_site_name.grid(sticky=tk.W, row=4, column=0, padx=self.xd, pady=self.yd) self.e_site_name = tk.Entry(self, width=self.w_e, textvariable=self.prj_name) self.e_site_name.grid(sticky=tk.EW, row=4, column=1, padx=self.xd, pady=self.yd) self.l_site_name_help = tk.Label( self, fg="gray26", text="(String, no spaces, example: MySite)") self.l_site_name_help.grid(sticky=tk.W, row=4, column=2, padx=self.xd, pady=self.yd) self.b_val_var = tk.Button(self, text="VALIDATE VARIABLES", command=lambda: self.verify_variables()) self.b_val_var.grid(sticky=tk.EW, row=8, column=0, columnspan=3, padx=self.xd, pady=self.yd * 2) self.l_placeholder1 = tk.Label( self, fg="white", background="gray45", text="ASSESS, DELINEATE AND STABILIZE PLANTINGS") self.l_placeholder1.grid(sticky=tk.EW, row=9, column=0, columnspan=3, padx=self.xd, pady=self.yd * 2) self.l_vege_cr = tk.Label( self, text="Do not plant where expected lifespans are less than:") self.l_vege_cr.grid(sticky=tk.W, row=10, column=0, padx=self.xd, pady=self.yd) self.e_vege_cr = tk.Entry(self, width=self.w_e, textvariable=self.vege_cr) self.e_vege_cr.grid(sticky=tk.EW, row=10, column=1, padx=self.xd, pady=self.yd) self.l_vege_cr_help = tk.Label( self, fg="gray26", text=" years (float number, example: 2.5)") self.l_vege_cr_help.grid(sticky=tk.W, row=10, column=2, padx=self.xd, pady=self.yd) self.l_vege_stab_cr = tk.Label( self, text="Stabilize plants where expected lifespans are less than:") self.l_vege_stab_cr.grid(sticky=tk.W, row=11, column=0, padx=self.xd, pady=self.yd) self.e_vege_stab_cr = tk.Entry(self, width=self.w_e, textvariable=self.vege_stab_cr) self.e_vege_stab_cr.grid(sticky=tk.EW, row=11, column=1, padx=self.xd, pady=self.yd) self.l_vege_stab_cr_help = tk.Label( self, fg="gray26", text=" years (should be higher than above value)") self.l_vege_stab_cr_help.grid(sticky=tk.W, row=11, column=2, padx=self.xd, pady=self.yd) self.l_condition_pl = tk.Label( self, text="Select plant Max Lifespan Condition: ") self.l_condition_pl.grid(sticky=tk.W, row=12, column=0, padx=self.xd, pady=self.yd) self.sb_condition_pl = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_pl.grid(sticky=tk.W, row=12, column=2, padx=0, pady=self.yd) self.lb_condition_pl = tk.Listbox( self, height=3, width=self.w_lb, yscrollcommand=self.sb_condition_pl.set) self.lb_condition_pl.grid(sticky=tk.EW, row=12, column=1, padx=self.xd, pady=self.yd) self.lb_condition_pl.insert(tk.END, "Validate Variables") self.sb_condition_pl.config(command=self.lb_condition_pl.yview) self.b_s20 = tk.Button(self, text="Place best vegetation plantings", command=lambda: self.start_app("s2X")) self.b_s20.grid(sticky=tk.EW, row=13, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_s20["state"] = "disabled" self.b_s20_help = tk.Button(self, width=14, fg="blue", bg="white", text="Info (help)", command=lambda: self.help_info("s2X")) self.b_s20_help.grid(sticky=tk.E, row=13, column=2, padx=self.xd, pady=self.yd * 2) self.l_placeholder2 = tk.Label(self, fg="white", background="gray45", text="TERRAIN STABILIZATION") self.l_placeholder2.grid(sticky=tk.EW, row=14, column=0, columnspan=3, padx=self.xd, pady=self.yd * 2) self.l_ter_cr = tk.Label(self, text="Target lifespan of surface grains:") self.l_ter_cr.grid(sticky=tk.W, row=15, column=0, padx=self.xd, pady=self.yd) self.e_ter_cr = tk.Entry(self, width=self.w_e, textvariable=self.ter_cr) self.e_ter_cr.grid(sticky=tk.EW, row=15, column=1, padx=self.xd, pady=self.yd) self.l_ter_cr_help = tk.Label( self, fg="gray26", text=" years (float number, example: 2.5)") self.l_ter_cr_help.grid(sticky=tk.W, row=15, column=2, padx=self.xd, pady=self.yd) self.l_condition_ter = tk.Label( self, text="Select nat. eng. MaxLifespan Condition: ") self.l_condition_ter.grid(sticky=tk.W, row=18, column=0, padx=self.xd, pady=self.yd) self.sb_condition_ter = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_ter.grid(sticky=tk.W, row=18, column=2, padx=0, pady=self.yd) self.lb_condition_ter = tk.Listbox( self, height=3, width=self.w_lb, yscrollcommand=self.sb_condition_ter.set) self.lb_condition_ter.grid(sticky=tk.EW, row=18, column=1, padx=self.xd, pady=self.yd) self.lb_condition_ter.insert(tk.END, "Validate Variables") self.sb_condition_ter.config(command=self.lb_condition_ter.yview) self.b_s30_def = tk.Button(self, width=14, bg="white", text="Set stability drivers", command=lambda: self.set_stab_vars()) self.b_s30_def.grid(sticky=tk.E, row=18, column=2, padx=self.xd, pady=self.yd * 2) self.b_s30 = tk.Button(self, text="Stabilize terrain", command=lambda: self.start_app("s30")) self.b_s30.grid(sticky=tk.EW, row=20, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_s30["state"] = "disabled" self.b_s30_help = tk.Button(self, width=14, fg="blue", bg="white", text="Info (help)", command=lambda: self.help_info("s30")) self.b_s30_help.grid(sticky=tk.E, row=20, column=2, padx=self.xd, pady=self.yd * 2) self.l_placeholder3 = tk.Label( self, fg="white", background="gray45", text=" NET GAIN IN SEASONAL HABITAT AREA ") self.l_placeholder3.grid(sticky=tk.EW, row=21, column=0, columnspan=3, padx=self.xd, pady=self.yd * 2) self.l_choose_fish = tk.Label( self, text= "1) Select at least one fish species-lifestage (Physical Habitat)." ) self.l_choose_fish.grid(sticky=tk.W, row=22, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_show_fish = tk.Button( self, width=14, background="white", text="Show selected fish", command=lambda: self.help_info("fish_selected")) self.b_show_fish.grid(sticky=tk.E, row=22, column=2, padx=self.xd, pady=self.yd) self.cb_cover_pre = tk.Checkbutton( self, text="Optional: Apply cover to pre-project", variable=self.cover_app_pre, onvalue=True, offvalue=False) self.cb_cover_pre.grid(sticky=tk.W, row=23, column=0, padx=self.xd, pady=self.yd) self.cb_cover_pre.deselect() self.cb_cover_post = tk.Checkbutton( self, text="Optional: Apply cover to post-project", variable=self.cover_app_post, onvalue=True, offvalue=False) self.cb_cover_post.grid(sticky=tk.W, row=23, column=1, columnspan=2, padx=self.xd, pady=self.yd) self.cb_cover_post.deselect() # self.cb_apply_wua = tk.Checkbutton(self, text="Use WUA", variable=self.apply_wua, onvalue=True, offvalue=False) # self.cb_apply_wua.grid(sticky=tk.E, row=23, column=2, padx=self.xd, pady=self.yd) # self.cb_apply_wua.deselect() self.l_condition_i = tk.Label( self, text="2) Select pre-project condition (SHArC/SHArea): ") self.l_condition_i.grid(sticky=tk.W, row=25, column=0, padx=self.xd, pady=self.yd) self.sb_condition_i = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_i.grid(sticky=tk.W, row=25, column=2, padx=0, pady=self.yd) self.lb_condition_i = tk.Listbox( self, height=3, width=self.w_lb, yscrollcommand=self.sb_condition_i.set) self.lb_condition_i.grid(sticky=tk.EW, row=25, column=1, padx=self.xd, pady=self.yd) self.lb_condition_i.insert(tk.END, "Validate Variables") self.sb_condition_i.config(command=self.lb_condition_i.yview) self.b_select_c_i = tk.Button( self, width=14, background="white", text="Confirm Selection", command=lambda: self.select_condition("chsi_initial")) self.b_select_c_i.grid(sticky=tk.E, row=25, column=2, padx=self.xd, pady=self.yd) self.l_condition_p = tk.Label( self, text="3) Select post-project condition (SHArC/SHArea): ") self.l_condition_p.grid(sticky=tk.W, row=28, column=0, padx=self.xd, pady=self.yd) self.sb_condition_p = tk.Scrollbar(self, orient=tk.VERTICAL) self.sb_condition_p.grid(sticky=tk.W, row=28, column=2, padx=0, pady=self.yd) self.lb_condition_p = tk.Listbox( self, height=3, width=self.w_lb, yscrollcommand=self.sb_condition_p.set) self.lb_condition_p.grid(sticky=tk.EW, row=28, column=1, padx=self.xd, pady=self.yd) self.lb_condition_p.insert(tk.END, "Validate Variables") self.sb_condition_p.config(command=self.lb_condition_i.yview) self.b_select_c_p = tk.Button( self, width=14, background="white", text="Confirm Selection", command=lambda: self.select_condition("chsi_project")) self.b_select_c_p.grid(sticky=tk.E, row=28, column=2, padx=self.xd, pady=self.yd) self.b_s40 = tk.Button( self, text="Calculate Net gain in Seasonal Habitat Area (SHArea)", command=lambda: self.start_app("s40")) self.b_s40.grid(sticky=tk.EW, row=30, column=0, columnspan=2, padx=self.xd, pady=self.yd) self.b_s40["state"] = "disabled" self.b_s40_help = tk.Button(self, width=14, fg="blue", bg="white", text="Info (help)", command=lambda: self.help_info("s40")) self.b_s40_help.grid(sticky=tk.E, row=23, column=2, padx=self.xd, pady=self.yd)
def create_cutscreen(self, gcodeDir, title): tk.Button(master=self, text='Back', command=lambda: self.create_main()).pack(side='top', anchor='w') self.w = tk.Label(self, text=title, font=("Helvetica", 36)) self.w.pack() tk.Button(master=self, text='Select All', command=lambda: self.select_all()).pack(side='top', anchor='center') # Loop through files in given dir and create check boxes directory = os.fsencode(gcodeDir) self.checkboxes = [] self.zValues = [] for file in sorted(os.listdir(directory), key=alphanum_key): filename = os.fsdecode(file) if filename.endswith( ".gcode" ) and "_COMPILED_" not in filename and "000" not in filename: fm = tk.Frame(self) chkVar = tk.IntVar() chkVar.set(0) zVar = tk.DoubleVar() zVar.set(' 0.000') self.zValues.append((zVar, filename)) self.checkboxes.append((chkVar, filename)) zLabel = tk.Label(fm, text=" 0.00", textvariable=zVar, font=("Courier", 14)) self.zLabels.append((zLabel, filename)) zLabel.pack(side="left", fill="x") tk.Checkbutton(fm, text=filename, variable=chkVar).pack(side="left") tk.Button(fm, text="+0.01", bg="blue", command=partial(self.changeZindexValue, 0.01, filename)).pack(side="right") tk.Button(fm, text="+0.005", bg="blue", command=partial(self.changeZindexValue, 0.005, filename)).pack(side="right") tk.Button(fm, text="-0.005", bg="green", command=partial(self.changeZindexValue, -0.005, filename)).pack(side="right") tk.Button(fm, text="-0.01", bg="green", command=partial(self.changeZindexValue, -0.01, filename)).pack(side="right") fm.pack(fill="both", expand="yes", side="top") tk.Button(master=self, text='Generate GCode', command=lambda: self.generateGcode(gcodeDir, title)).pack( side='top', anchor='center') self.quit = tk.Button(self, text="QUIT", fg="red", command=root.destroy) self.quit.pack(side="bottom")
def main(): """Главная функция главного модуля. Создаёт объекты графического дизайна библиотеки tkinter: окно, холст, фрейм с кнопками, кнопки. """ global physical_time global displayed_time global time_step global time_speed global space global start_button print('Modelling started!') physical_time = 0 root = tkinter.Tk() root.title("Kepler's laws of motion") window_size = str(window_width) + "x" + str(window_height + 60) root.geometry(window_size) # космическое пространство отображается на холсте типа Canvas space = tkinter.Canvas(root, width=window_width, height=window_height, bg="black") space.pack(side=tkinter.TOP) # нижняя панель с кнопками frame = tkinter.Frame(root) frame.pack(side=tkinter.BOTTOM) start_button = tkinter.Button(frame, text="Start", command=start_execution, width=6) start_button.pack(side=tkinter.LEFT) time_step = tkinter.DoubleVar() time_step.set(1) time_step_entry = tkinter.Entry(frame, textvariable=time_step) time_step_entry.pack(side=tkinter.LEFT) time_speed = tkinter.DoubleVar() scale = tkinter.Scale(frame, variable=time_speed, orient=tkinter.HORIZONTAL) scale.pack(side=tkinter.LEFT) load_file_button = tkinter.Button(frame, text="Open file...", command=open_file_dialog) load_file_button.pack(side=tkinter.LEFT) save_file_button = tkinter.Button(frame, text="Save to file...", command=save_file_dialog) save_file_button.pack(side=tkinter.LEFT) open_diagram_button = tkinter.Button(frame, text="View stats", command=open_diagram) open_diagram_button.pack(side=tkinter.LEFT) displayed_time = tkinter.StringVar() displayed_time.set(str(physical_time) + " seconds gone") time_label = tkinter.Label(frame, textvariable=displayed_time, width=30) time_label.pack(side=tkinter.RIGHT) root.mainloop() print('Modelling finished!')
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) # #object is label, bg background, fg foreground # #input labels ilabel1 = tk.Label(self, text="Exhaust Velocity (m/s)", fg="black").grid(row=4, sticky="e") ilabel2 = tk.Label(self, text="Launch Alitutde (m)", fg="black").grid(row=5, sticky="e") ilabel3 = tk.Label(self, text="Target Alitutde (m)", fg="black").grid(row=6, sticky="e") ilabel4 = tk.Label(self, text="Estimate burn time (s)", fg="black").grid(row=7, sticky="e") ilabel5 = tk.Label(self, text="Empty mass target (kg)", fg="black").grid(row=8, sticky="e") ilabel6 = tk.Label(self, text="Start nozzle flow rate (kg/s)", fg="black").grid(row=9, sticky="e") # #output labels olabel1 = tk.Label(self, text="Specific gravitational potential (kJ)").grid( row=11, sticky="e") olabel2 = tk.Label(self, text="Velocity (m/s)").grid(row=12, sticky="e") olabel3 = tk.Label(self, text="Gravity loss (m/s)").grid(row=13, sticky="e") olabel4 = tk.Label(self, text="Drag loss (m/s)").grid(row=14, sticky="e") olabel5 = tk.Label(self, text="Total velocity (m/s)").grid(row=15, sticky="e") olabel6 = tk.Label(self, text="Mass ratio").grid(row=16, sticky="e") olabel7 = tk.Label(self, text="Propellant mass (kg)").grid(row=17, sticky="e") olabel8 = tk.Label(self, text="Total mass (kg)").grid(row=18, sticky="e") olabel9 = tk.Label(self, text="Start propellant mass (kg)").grid(row=19, sticky="e") olabel10 = tk.Label(self, text="Final vapour mass (kg)").grid(row=20, sticky="e") olabel11 = tk.Label(self, text="Liquid burn time (s)").grid(row=21, sticky="e") global exvel global lalt global talt global tb global emt global snfr exvel = tk.DoubleVar() lalt = tk.DoubleVar() talt = tk.DoubleVar() tb = tk.DoubleVar() emt = tk.DoubleVar() snfr = tk.DoubleVar() self.entry1 = tk.Entry(self, textvariable=exvel) self.entry1.grid(row=4, column=1) self.entry2 = tk.Entry(self, textvariable=lalt) self.entry2.grid(row=5, column=1) self.entry3 = tk.Entry(self, textvariable=talt) self.entry3.grid(row=6, column=1) self.entry4 = tk.Entry(self, textvariable=tb) self.entry4.grid(row=7, column=1) self.entry5 = tk.Entry(self, textvariable=emt) self.entry5.grid(row=8, column=1) self.entry6 = tk.Entry(self, textvariable=snfr) self.entry6.grid(row=9, column=1) button1 = ttk.Button(self, text="Calculate", command=self.initial_estimates1).grid(row=10, column=0)
def populate_portfolio(self): ''' Get all symbol info from Binance needed to populate user portfolio data and execute trades ''' self.coins = self.coins_base self.portfolio.delete(*self.portfolio.get_children()) exchange_coins = [] trade_currency = self.trade_currency self.trade_coin = trade_currency #update the GUI context self.key_label.destroy() self.key_entry.destroy() self.secret_label.destroy() self.secret_entry.destroy() self.login.destroy() updatetext = tk.StringVar() updatetext.set('Initializing') self.progresslabel = tk.Label(self.controls_view, textvariable=updatetext) self.progresslabel.grid(row=1, column=0, columnspan=4, sticky=tk.E + tk.W) progress_var = tk.DoubleVar() progress = 0 progress_var.set(progress) self.progressbar = tkinter.ttk.Progressbar(self.controls_view, variable=progress_var, maximum=len(self.coins)) self.progressbar.grid(row=0, column=0, columnspan=4, sticky=tk.E + tk.W) for coin in self.coins['coin']: self.progressbar.update() progress += 1 progress_var.set(progress) updatetext.set('Fetching {0} account information'.format(coin)) self.progresslabel.update() pair = coin + trade_currency balance = self.client.get_asset_balance(asset=coin) if coin != trade_currency: price = float( self.client.get_symbol_ticker(symbol=pair)['price']) symbolinfo = self.client.get_symbol_info( symbol=pair)['filters'] minvalue = float(symbolinfo[3]['minNotional']) if self.min_trade_value is not None: minvalue = self.min_trade_value row = { 'coin': coin, 'exchange_balance': float(balance['free']), 'locked_balance': float(balance['locked']), 'minprice': float(symbolinfo[0]['minPrice']), 'maxprice': float(symbolinfo[0]['maxPrice']), 'ticksize': float(symbolinfo[0]['tickSize']), 'minqty': float(symbolinfo[2]['minQty']), 'maxqty': float(symbolinfo[2]['maxQty']), 'stepsize': float(symbolinfo[2]['stepSize']), 'minnotional': minvalue, 'symbol': pair, 'askprice': price, 'bidprice': price, 'price': price, 'last_placement': None, 'last_execution': None } else: fixed_balance = self.coins.loc[self.coins['coin'] == coin]['fixed_balance'] row = { 'coin': coin, 'exchange_balance': float(balance['free']), 'locked_balance': float(balance['locked']), 'minprice': 0, 'maxprice': 0, 'ticksize': 0, 'minqty': 0, 'maxqty': 0, 'stepsize': 0, 'minnotional': 0, 'symbol': coin + coin, 'askprice': 1.0, 'bidprice': 1.0, 'price': 1.0, 'last_placement': None, 'last_execution': None } exchange_coins.append(row) exchange_coins = pd.DataFrame(exchange_coins) self.coins = pd.merge(self.coins, exchange_coins, on='coin', how='outer') self.coins['value'] = self.coins.apply( lambda row: row.price * (row.exchange_balance + row.fixed_balance), axis=1) self.total = np.sum(self.coins['value']) self.coins['actual'] = self.coins.apply( lambda row: 100.0 * row.value / self.total, axis=1) self.update_status() i = 0 for row in self.coins.itertuples(): self.portfolio.insert( '', i, iid=row.coin, text=row.coin, values=(row.fixed_balance, row.exchange_balance, row.locked_balance, '{0} %'.format(row.allocation), '{0:.2f} %'.format(row.actual), round_decimal(row.price, row.ticksize), round_decimal(row.price, row.ticksize), '', '')) i += 1 updatetext.set('Testing connection'.format(coin)) self.dryrun() self.progressbar.destroy() self.progresslabel.destroy() self.automate = tk.BooleanVar() self.automate.set(False) self.automate_text = tk.StringVar() self.automate_text.set('Start Automation') self.toggle_automate = tk.Button( self.controls_view, textvariable=self.automate_text, command=lambda: self.automation(toggle=True)) self.toggle_automate.grid(row=0, column=0, rowspan=2, columnspan=2, sticky=tk.E + tk.W + tk.N + tk.S) self.sell_button = tk.Button(self.controls_view, text='Execute Sells', command=self.execute_sells) self.sell_button.grid(row=0, column=2, columnspan=2, sticky=tk.E + tk.W) self.buy_button = tk.Button(self.controls_view, text='Execute Buys', command=self.execute_buys) self.buy_button.grid(row=1, column=2, columnspan=2, sticky=tk.E + tk.W)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) #geometry ilabel1 = tk.Label(self, text="Geometry", fg="black").grid(row=4, sticky="e") ilabel2 = tk.Label(self, text="Injector hole diameter (mm)", fg="black").grid(row=5, sticky="e") ilabel3 = tk.Label( self, text="Oxidiser/Fuel ratio", fg="black", ).grid(row=6, sticky="e") ilabel4 = tk.Label(self, text="Tank pressure - Chamber pressure (Bar)", fg="black").grid(row=7, sticky="e") ilabel5 = tk.Label(self, text="Loss coefficient", fg="black").grid(row=8, sticky="e") ilabel6 = tk.Label(self, text="Density of oxidiser (kg/m^3)", fg="black").grid(row=9, sticky="e") ilabel7 = tk.Label(self, text="Mass flow rate oxidiser (kg/s)", fg="black").grid(row=10, sticky="e") #stress ilabel9 = tk.Label(self, text="Stress Analysis", fg="black").grid(row=12, sticky="e") ilabel10 = tk.Label(self, text="Max pressure drop (Pa)", fg="black").grid(row=13, sticky="e") ilabel11 = tk.Label(self, text="Poisson Ratio", fg="black").grid(row=14, sticky="e") ilabel12 = tk.Label(self, text="Yield Stress (Pa)", fg="black").grid(row=15, sticky="e") ilabel13 = tk.Label(self, text="Radius of injector (m)", fg="black").grid(row=16, sticky="e") ilabel14 = tk.Label(self, text="Safety Factor", fg="black").grid(row=17, sticky="e") global ihd global of global tpcp global lc global doo global mfrn global mpd global Pr global Ys global roi global SF ihd = tk.DoubleVar() of = tk.DoubleVar() tpcp = tk.DoubleVar() lc = tk.DoubleVar() doo = tk.DoubleVar() mfrn = tk.DoubleVar() mpd = tk.DoubleVar() Pr = tk.DoubleVar() Ys = tk.DoubleVar() roi = tk.DoubleVar() SF = tk.DoubleVar() self.entry1 = tk.Entry(self, textvariable=ihd) self.entry1.grid(row=5, column=1) self.entry2 = tk.Entry(self, textvariable=of) self.entry2.grid(row=6, column=1) self.entry3 = tk.Entry(self, textvariable=tpcp) self.entry3.grid(row=7, column=1) self.entry4 = tk.Entry(self, textvariable=lc) self.entry4.grid(row=8, column=1) self.entry5 = tk.Entry(self, textvariable=doo) self.entry5.grid(row=9, column=1) self.entry6 = tk.Entry(self, textvariable=mfrn) self.entry6.grid(row=10, column=1) self.entry7 = tk.Entry(self, textvariable=mpd) self.entry7.grid(row=13, column=1) self.entry8 = tk.Entry(self, textvariable=Pr) self.entry8.grid(row=14, column=1) self.entry9 = tk.Entry(self, textvariable=Ys) self.entry9.grid(row=15, column=1) self.entry10 = tk.Entry(self, textvariable=roi) self.entry10.grid(row=16, column=1) self.entry11 = tk.Entry(self, textvariable=SF) self.entry11.grid(row=17, column=1) olabel1 = tk.Label(self, text="Area of orifice (m^2)").grid(row=5, column=2, sticky="e") olabel2 = tk.Label(self, text="Number of orificies").grid(row=6, column=2, sticky="e") olabel3 = tk.Label(self, text="Thickness (mm)").grid(row=13, column=2, sticky="e") button1 = tk.Button(self, text="Calculate", command=self.injectorcalc1).grid(row=11, column=0) button2 = tk.Button(self, text="Calculate", command=self.injectorcalcstress1).grid(row=18, column=0)
def init_gui(self): """ Setups all the parameters (and their values) needed by the GUI. Includes window size, components, background, and more. Args: None Returns: None """ self.root.title('Arm Solutions') self.root.geometry("1200x800") self.background_image = Image.open("Flat_colorful_background.png") self.background_image = self.background_image.resize((2000,2000), Image.ANTIALIAS) self.background_image = ImageTk.PhotoImage(self.background_image) self.label = tkinter.Label(self.root, image=self.background_image) self.label.image = self.background_image self.label.place(x=0,y=0, relwidth=1, relheight=1) self.root.grid_columnconfigure(1, weight=1) self.root.grid_columnconfigure(0, weight=1) self.root.option_add('*tearOff', 'FALSE') # Disables ability to tear menu bar into own window # self.systemStatusLabelText = tkinter.StringVar() self.systemStatusLabel = tkinter.Label(textvariable= self.systemStatusLabelText , bg = '#e81a1a', width = 25) self.startup_button = tkinter.Button(self.root, text ="Start Up/Resume System", command = self.startSystem, height=3, width= 35, bg = '#499c5f') self.pause_button = tkinter.Button(self.root, text ="Put System in Standby", command = self.pauseSystem, height=3, width= 35, bg ='#f9ff54') self.settings_button = tkinter.Button(self.root, text ="System Settings", command = self.systemSettings, height=3, width= 35, bg = '#adaaaa') self.exit_button = tkinter.Button(self.root, text ="Shut Down System", command = self.on_exit, height=3, width= 35, bg = '#e81a1a') self.imageFrame = tkinter.Frame(self.root) self.imageFrame.grid(row=0, column=1, padx=10, pady=50, rowspan=4) self.startup_button.grid(row=0,column=0, padx=50, pady=(60,100)) self.pause_button.grid(row=1,column=0, padx=50, pady=(0,100)) self.settings_button.grid(row=2, column=0, padx=50, pady=(0,100)) self.exit_button.grid(row=3, column=0, padx=50) self.systemStatusLabel.grid(row=3, column=1, pady=10, padx=240) self.systemStatusLabel.config(font=("New Times Roman", 20)) self.startup_button.config(font=("New Times Roman", 16)) self.pause_button.config(font=("New Times Roman", 16)) self.settings_button.config(font=("New Times Roman", 16)) self.exit_button.config(font=("New Times Roman", 16)) # Menu Bar self.menubar = Menubar(self.root) # Padding for child in self.winfo_children(): child.grid_configure(padx=10, pady=5) self.lmain = tkinter.Label(self.imageFrame) #Variables used later on self.speed = tkinter.DoubleVar() self.systemStatusLabelText.set("System Status - Offline")
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) # label1=tk.Label(self,text="Combustion Chamber", font = LARGE_FONT) # label1.grid(row=0,column=0) ilabel1 = tk.Label(self, text="Average regression rate (mm/s)", fg="black").grid(row=0, sticky="e") ilabel2 = tk.Label(self, text="Vapour average regression rate (mm/s)", fg="black").grid(row=1, sticky="e") ilabel3 = tk.Label( self, text="Density of fuel (kg/m^3)", fg="black", ).grid(row=2, sticky="e") ilabel4 = tk.Label( self, text="Maximum Flux (kg/s/m^2)", fg="black", ).grid(row=3, sticky="e") global avg_rate global vap_avg_rate global fuel_density global max_flux avg_rate = tk.DoubleVar() vap_avg_rate = tk.DoubleVar() fuel_density = tk.DoubleVar() max_flux = tk.DoubleVar() self.entry1 = tk.Entry(self, textvariable=avg_rate) self.entry1.grid(row=0, column=1) self.entry2 = tk.Entry(self, textvariable=vap_avg_rate) self.entry2.grid(row=1, column=1) self.entry3 = tk.Entry(self, textvariable=fuel_density) self.entry3.grid(row=2, column=1) self.entry4 = tk.Entry(self, textvariable=max_flux) self.entry4.grid(row=3, column=1) button1 = tk.Button(self, text="Calculate", command=self.portgeom1).grid(row=4, column=0) olabel1 = tk.Label(self, text="Oxidiser mass (kg)").grid(row=5, column=0, sticky="e") olabel2 = tk.Label(self, text="Fuel mass (kg)").grid(row=6, column=0, sticky="e") olabel3 = tk.Label(self, text="End flow rate (kg/s)").grid(row=7, column=0, sticky="e") olabel4 = tk.Label(self, text="Initial port area (m^2)").grid(row=8, column=0, sticky="e") olabel5 = tk.Label(self, text="Initial port diameter (m)").grid(row=9, column=0, sticky="e") olabel6 = tk.Label(self, text="Final liquid port diameter(mm)").grid( row=10, column=0, sticky="e") olabel7 = tk.Label(self, text="Final port diameter(mm)").grid(row=11, column=0, sticky="e") olabel8 = tk.Label(self, text="Mid burn port diamater (mm)").grid(row=12, column=0, sticky="e") olabel9 = tk.Label(self, text="Mid flow rate (kg/s)").grid(row=13, column=0, sticky="e") olabel10 = tk.Label(self, text="Grain length (m)").grid(row=14, column=0, sticky="e") olabel11 = tk.Label(self, text="Port length (m)").grid(row=15, column=0, sticky="e")
def setup_multicolor(self): """ initial setup of multicolor options and variables""" # Setup the options for multicolor multicolormasterframe = tk.Frame(self.tab_configure) channel_choices = sorted(list(self.data.keys())) rgb = ['red', 'green', 'blue'] self.multicolorframes = { color: tk.Frame(multicolormasterframe, bg=color) for color in rgb } self.multicolorlabels = { color: tk.Label(self.multicolorframes[color], text=color, bg=color, width=10) for color in rgb } self.multicolorvars = {color: tk.StringVar() for color in rgb} self.multicolorpower = {color: tk.DoubleVar() for color in rgb} self.multicolormin = {color: tk.DoubleVar() for color in rgb} self.multicolormax = {color: tk.DoubleVar() for color in rgb} self.multicolordropdowns = { color: tk.OptionMenu(self.multicolorframes[color], self.multicolorvars[color], *channel_choices) for color in rgb } self.multicolorscales = { color: tk.Scale( self.multicolorframes[color], variable=self.multicolorpower[color], orient=tk.HORIZONTAL, from_=self.config.ranges['multi_color_power_min'], to_=self.config.ranges['multi_color_power_max'], bg=color, resolution=self.config.ranges['multi_color_power_resolution'], length=200) for color in rgb } self.multicolorminscale = { color: tk.Scale(self.multicolorframes[color], variable=self.multicolormin[color], orient=tk.HORIZONTAL, from_=0, to_=self.config.ranges['multi_color_vmin'], bg=color, resolution=self.config.ranges['multi_color_vresolution'], length=200) for color in rgb } self.multicolormaxscale = { color: tk.Scale(self.multicolorframes[color], variable=self.multicolormax[color], orient=tk.HORIZONTAL, from_=self.config.ranges['multi_color_vmax'], to_=100, bg=color, resolution=self.config.ranges['multi_color_vresolution'], length=200) for color in rgb } for color in rgb: self.multicolorvars[color].set( self.config.products_map[self.config.default[color]]) self.multicolorpower[color].set(self.config.default[color + "_power"]) self.multicolormin[color].set(0) self.multicolormax[color].set(100) self.multicolordropdowns[color].config(bg=color, width=10) self.multicolorlabels[color].pack(side=tk.LEFT) self.multicolorscales[color].pack(side=tk.RIGHT) self.multicolormaxscale[color].pack(side=tk.RIGHT) self.multicolorminscale[color].pack(side=tk.RIGHT) self.multicolordropdowns[color].pack() self.multicolorframes[color].pack(fill=tk.BOTH) multicolormasterframe.grid(row=1, column=0, columnspan=5, rowspan=3)
#=========================================================================== popup.protocol("WM_DELETE_WINDOW", on_closing) popup.bind('<Escape>', lambda e: popup.destroy()) #=========================================================================== # Label text #=========================================================================== plabletextstr = StringVar() plabletextstr.set("") tk.Label(popup, textvariable=plabletextstr).grid(row=0, column=0) #=========================================================================== # Progress bar #=========================================================================== progress = 0 progress_var = tk.DoubleVar() progress_bar = ttk.Progressbar(popup, variable=progress_var, length=490, maximum=100) progress_bar.grid(row=1, column=0) #.pack(fill=tk.X, expand=1, side=tk.BOTTOM) progress_bar.place(x=5, y=25) popup.pack_slaves() #=========================================================================== # Read number of line 'data_generated.txt' #=========================================================================== num_data_generated_lines = 0 num_data_generated_lines = sum( 1 for line in open(progress_bar_result_file_path))
def createWidgets(self): # Tab Control introduced here -------------------------------------- tabControl = ttk.Notebook(self.win) # Create Tab Control tab1 = ttk.Frame(tabControl) # Create a tab tabControl.add(tab1, text='Tab 1') # Add the tab tab2 = ttk.Frame(tabControl) # Add a second tab tabControl.add(tab2, text='Tab 2') # Make second tab visible tabControl.pack(expand=1, fill="both") # Pack to make visible # ~ Tab Control introduced here ----------------------------------------- # We are creating a container frame to hold all other widgets self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) # Changing our Label ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') # Adding a Button self.action = ttk.Button(self.monty, text="Click Me!", command=self.clickMe) self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (1, 2, 4, 42, 100) numberChosen.grid(column=1, row=1) numberChosen.current(0) # Adding a Spinbox widget using a set of values self.spin = Spinbox(self.monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command=self._spin) self.spin.grid(column=0, row=2) # Using a scrolled Text control scrolW = 30 scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) #------------------------------------------------------------------------- # Adding another Button self.action = ttk.Button(self.monty, text="Clear Text", command=self.clearScrol) self.action.grid(column=2, row=2) # Adding more Feature Buttons for idx in range(3): b = ttk.Button(self.monty, text="Feature" + str(idx + 1)) b.grid(column=idx, row=4) ########################### # Tab Control 2 refactoring ----------------------------------------- # We are creating a container frame to hold all other widgets -- Tab2 self.monty2 = ttk.LabelFrame(tab2, text=' Holy Grail ') self.monty2.grid(column=0, row=0, padx=8, pady=4) # Creating three checkbuttons chVarDis = tk.IntVar() check1 = tk.Checkbutton(self.monty2, text="Disabled", variable=chVarDis, state='disabled') check1.select() check1.grid(column=0, row=0, sticky=tk.W) self.chVarUn = tk.IntVar() self.check2 = tk.Checkbutton(self.monty2, text="UnChecked", variable=self.chVarUn) self.check2.deselect() self.check2.grid(column=1, row=0, sticky=tk.W) self.chVarEn = tk.IntVar() self.check3 = tk.Checkbutton(self.monty2, text="Toggle", variable=self.chVarEn) self.check3.deselect() self.check3.grid(column=2, row=0, sticky=tk.W) # trace the state of the two checkbuttons self.chVarUn.trace( 'w', lambda unused0, unused1, unused2: self.checkCallback()) self.chVarEn.trace( 'w', lambda unused0, unused1, unused2: self.checkCallback()) # ~ Tab Control 2 refactoring ----------------------------------------- # Radiobutton list colors = ["Blue", "Gold", "Red"] self.radVar = tk.IntVar() # Selecting a non-existing index value for radVar self.radVar.set(99) # Creating all three Radiobutton widgets within one loop for col in range(3): curRad = 'rad' + str(col) curRad = tk.Radiobutton(self.monty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall) curRad.grid(column=col, row=6, sticky=tk.W, columnspan=3) # And now adding tooltips ToolTip(curRad, 'This is a Radiobutton control.') # Create a container to hold labels labelsFrame = ttk.LabelFrame(self.monty2, text=' Labels in a Frame ') labelsFrame.grid(column=0, row=7) # Place labels into the container element - vertically ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0) ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1) # Add some space around each label for child in labelsFrame.winfo_children(): child.grid_configure(padx=8) # Creating a Menu Bar menuBar = Menu(tab1) self.win.config(menu=menuBar) # Add menu items fileMenu = Menu(menuBar, tearoff=0) fileMenu.add_command(label="New") fileMenu.add_separator() fileMenu.add_command(label="Exit", command=self._quit) menuBar.add_cascade(label="File", menu=fileMenu) # Add another Menu to the Menu Bar and an item helpMenu = Menu(menuBar, tearoff=0) helpMenu.add_command(label="About") menuBar.add_cascade(label="Help", menu=helpMenu) # Change the main windows icon self.win.iconbitmap('pyc.ico') # Using tkinter Variable Classes strData = tk.StringVar() strData.set('Hello StringVar') print(strData.get()) # Default tkinter Variable Classes intData = tk.IntVar() print(intData.get()) print(tk.DoubleVar()) print(tk.BooleanVar()) # It is not necessary to create a tk.StringVar() strData = tk.StringVar() strData = self.spin.get() print("Hello " + strData) # Printing the Global works print(GLOBAL_CONST) # call method self.usingGlobal() # Place cursor into name Entry nameEntered.focus() # Add a Tooltip to the Spinbox ToolTip(self.spin, 'This is a Spin control.') # Add Tooltips to more widgets ToolTip(nameEntered, 'This is an Entry control.') ToolTip(self.action, 'This is a Button control.') ToolTip(self.scr, 'This is a ScrolledText control.')
def __init__(self): tk.Toplevel.__init__(self) self.title('Data Augmentation') self.layout = { 'global': { 'start': { 'x': 15, 'y': 20 }, 'space': { 'x': 15, 'y': 25 }, 'tiny_space': { 'x': 5, 'y': 10 } } } self.data_augmentation_entity = None self.window_width = 750 self.window_height = 220 self.layout_utils = LayoutGUI(self.layout, self.window_width) screenwidth = self.winfo_screenwidth() screenheight = self.winfo_screenheight() size = '%dx%d+%d+%d' % (self.window_width, self.window_height, (screenwidth - self.window_width) / 2, (screenheight - self.window_height) / 2) self.geometry(size) # ============================= Group 4 ===================================== self.label_frame_augmentation = ttk.Labelframe( self, text='Data Augmentation') self.label_frame_augmentation.place( x=self.layout['global']['start']['x'], y=self.layout['global']['start']['y'], width=725, height=150) # 二值化 - 标签 self.binaryzation_text = ttk.Label(self, text='Binaryzation', anchor=tk.W) self.layout_utils.inside_widget( src=self.binaryzation_text, target=self.label_frame_augmentation, width=72, height=20, ) # 二值化 - 输入框 self.binaryzation_val = tk.StringVar() self.binaryzation_val.set(-1) self.binaryzation_entry = ttk.Entry(self, textvariable=self.binaryzation_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.binaryzation_entry, target=self.binaryzation_text, width=55, height=20, tiny_space=True) # 滤波 - 标签 self.median_blur_text = ttk.Label(self, text='Median Blur', anchor=tk.W) self.layout_utils.next_to_widget(src=self.median_blur_text, target=self.binaryzation_entry, width=80, height=20, tiny_space=False) # 滤波 - 输入框 self.median_blur_val = tk.IntVar() self.median_blur_val.set(-1) self.median_blur_entry = ttk.Entry(self, textvariable=self.median_blur_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.median_blur_entry, target=self.median_blur_text, width=52, height=20, tiny_space=True) # 高斯模糊 - 标签 self.gaussian_blur_text = ttk.Label(self, text='Gaussian Blur', anchor=tk.W) self.layout_utils.next_to_widget(src=self.gaussian_blur_text, target=self.median_blur_entry, width=85, height=20, tiny_space=False) # 高斯模糊 - 输入框 self.gaussian_blur_val = tk.IntVar() self.gaussian_blur_val.set(-1) self.gaussian_blur_entry = ttk.Entry( self, textvariable=self.gaussian_blur_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.gaussian_blur_entry, target=self.gaussian_blur_text, width=62, height=20, tiny_space=True) # 椒盐噪声 - 标签 self.sp_noise_text = ttk.Label(self, text='Pepper Noise (0-1)', anchor=tk.W) self.layout_utils.next_to_widget(src=self.sp_noise_text, target=self.gaussian_blur_entry, width=110, height=20, tiny_space=False) # 椒盐噪声 - 输入框 self.sp_noise_val = tk.DoubleVar() self.sp_noise_val.set(-1) self.sp_noise_entry = ttk.Entry(self, textvariable=self.sp_noise_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.sp_noise_entry, target=self.sp_noise_text, width=71, height=20, tiny_space=True) # 旋转 - 标签 self.rotate_text = ttk.Label(self, text='Rotate (0-90)', anchor=tk.W) self.layout_utils.below_widget(src=self.rotate_text, target=self.binaryzation_text, width=72, height=20, tiny_space=True) # 旋转 - 输入框 self.rotate_val = tk.IntVar() self.rotate_val.set(-1) self.rotate_entry = ttk.Entry(self, textvariable=self.rotate_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.rotate_entry, target=self.rotate_text, width=55, height=20, tiny_space=True) # 随机空白边缘 - 标签 self.random_blank_text = ttk.Label(self, text='Blank Border', anchor=tk.W) self.layout_utils.next_to_widget(src=self.random_blank_text, target=self.rotate_entry, width=72, height=20, tiny_space=False) # 随机空白边缘 - 输入框 self.random_blank_val = tk.IntVar() self.random_blank_val.set(-1) self.random_blank_entry = ttk.Entry(self, textvariable=self.random_blank_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.random_blank_entry, target=self.random_blank_text, width=55, height=20, tiny_space=True) # 随机边缘位移 - 标签 self.random_transition_text = ttk.Label(self, text='Transition', anchor=tk.W) self.layout_utils.next_to_widget(src=self.random_transition_text, target=self.random_blank_entry, width=60, height=20, tiny_space=False) # 随机边缘位移 - 输入框 self.random_transition_val = tk.IntVar() self.random_transition_val.set(-1) self.random_transition_entry = ttk.Entry( self, textvariable=self.random_transition_val, justify=tk.LEFT) self.layout_utils.next_to_widget(src=self.random_transition_entry, target=self.random_transition_text, width=55, height=20, tiny_space=True) # 透视变换 - 多选框 self.warp_perspective_val = tk.IntVar() self.warp_perspective_val.set(0) self.warp_perspective = ttk.Checkbutton( self, text='Distortion', variable=self.warp_perspective_val, onvalue=1, offvalue=0) self.layout_utils.below_widget(src=self.warp_perspective, target=self.rotate_text, width=80, height=20, tiny_space=False) # 直方图均衡化 - 多选框 self.equalize_hist_val = tk.IntVar() self.equalize_hist_val.set(0) self.equalize_hist = ttk.Checkbutton(self, text='EqualizeHist', variable=self.equalize_hist_val, offvalue=0) self.layout_utils.next_to_widget(src=self.equalize_hist, target=self.warp_perspective, width=100, height=20, tiny_space=True) # 拉普拉斯 - 多选框 self.laplace_val = tk.IntVar() self.laplace_val.set(0) self.laplace = ttk.Checkbutton(self, text='Laplace', variable=self.laplace_val, onvalue=1, offvalue=0) self.layout_utils.next_to_widget(src=self.laplace, target=self.equalize_hist, width=64, height=20, tiny_space=True) # 随机亮度 - 多选框 self.brightness_val = tk.IntVar() self.brightness_val.set(0) self.brightness = ttk.Checkbutton(self, text='Brightness', variable=self.brightness_val, offvalue=0) self.layout_utils.next_to_widget(src=self.brightness, target=self.laplace, width=80, height=20, tiny_space=True) # 随机饱和度 - 多选框 self.saturation_val = tk.IntVar() self.saturation_val.set(0) self.saturation = ttk.Checkbutton(self, text='Saturation', variable=self.saturation_val, offvalue=0) self.layout_utils.next_to_widget(src=self.saturation, target=self.brightness, width=80, height=20, tiny_space=True) # 随机色相 - 多选框 self.hue_val = tk.IntVar() self.hue_val.set(0) self.hue = ttk.Checkbutton(self, text='Hue', variable=self.hue_val, offvalue=0) self.layout_utils.next_to_widget(src=self.hue, target=self.saturation, width=50, height=20, tiny_space=True) # 随机Gamma - 多选框 self.gamma_val = tk.IntVar() self.gamma_val.set(0) self.gamma = ttk.Checkbutton(self, text='Gamma', variable=self.gamma_val, offvalue=0) self.layout_utils.next_to_widget(src=self.gamma, target=self.hue, width=80, height=20, tiny_space=True) # 随机通道 - 多选框 self.channel_swap_val = tk.IntVar() self.channel_swap_val.set(0) self.channel_swap = ttk.Checkbutton(self, text='Channel Swap', variable=self.channel_swap_val, offvalue=0) self.layout_utils.next_to_widget(src=self.channel_swap, target=self.gamma, width=100, height=20, tiny_space=True) # 保存 - 按钮 self.btn_save = ttk.Button(self, text='Save Configuration', command=lambda: self.save_conf()) self.layout_utils.widget_from_right( src=self.btn_save, target=self.label_frame_augmentation, width=120, height=24, tiny_space=True)
def create_widgets(self): ''' Widget描画用処理 ''' #ラベルの描画 #ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label1 = tk.Label(self,text='Recipe Generation',font=("Helvetica", 20, "bold"),fg = "orange",bg = "white") self.label1.grid(row=0,column =0,sticky=tk.W) #キャンバスの描画 (Opencvで読み込んだ画像の表示) image_bgr = cv2.imread("online_kitchen.png") image_bgr = cv2.resize(image_bgr,(100,100)) # opencv画像をresize image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB) # imreadはBGRなのでRGBに変換 image_pil = Image.fromarray(image_rgb) # RGBをPILフォーマットに変換 self.image_tk = ImageTk.PhotoImage(image_pil) # ImageTkフォーマットへ変換 self.canvas = tk.Canvas(self, bg="grey", width=image_bgr.shape[0], height=image_bgr.shape[1]) self.canvas.create_image(0, 0, image=self.image_tk, anchor='nw') # ImageTk 画像配置 self.canvas.grid(row=1,column =0,columnspan=2,sticky=tk.W) #ボタンの描画 self.button1 = tk.Button(self,text="Hello World",bg='#f0e68c',command=self.func_callback_button) #ボタン文字列・コールバック関数の設定 self.button1.grid(row=2,column =0,sticky=tk.W) ##http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/anchors.html # #テキストボックスの描画 # self.textbox1 = tk.Entry(self,width=20) # self.textbox1.insert(tk.END,"default") #テキストボックス初期文字列の設定 # self.textbox1.grid(row=3,column =0,sticky=tk.W) #チェックボタンの描画 # self.chval = tk.BooleanVar(False) #チェックボタン初期値設定 # self.chbox1 = tk.Checkbutton(self, text = 'check1', variable = self.chval) #チェックボタンテキスト/変数紐づけ設定 # self.chbox1.grid(row=4,column =0,sticky=tk.W) #ラジオボタンの描画 (択一式) # self.radval = tk.IntVar(0) #ラジオボタンテキスト/変数紐づけ設定 # self.radbut1 = tk.Radiobutton(self, text = 'radio0', variable = self.radval, value = 0) #ラジオボタンテキスト/変数紐づけ設定 # self.radbut1.grid(row=5,column =0,sticky=tk.W) # self.radbut2 = tk.Radiobutton(self, text = 'radio1', variable = self.radval, value = 1) #ラジオボタンテキスト/変数紐づけ設定 # self.radbut2.grid(row=5,column =1,sticky=tk.W) # ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label2 = tk.Label(self, text='甘味', font=("Helvetica", 10, "normal"), fg="black", bg="white") self.label2.grid(row=3, column=0, sticky=tk.W) #シークバーの表示 self.seekbarval1 = tk.DoubleVar() #シークバー変数設定 self.seekbarval1.trace("w", self.func_callback_seekbar) #シークバー変数変動時コールバック関数設定 self.sc = ttk.Scale(self,variable=self.seekbarval1,orient=tk.HORIZONTAL,from_=0,to=255) #シークバー描画 self.sc.grid(row=4, column=0,columnspan=2, sticky=(tk.N,tk.E,tk.S,tk.W)) # ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label3 = tk.Label(self, text='塩味', font=("Helvetica", 10, "normal"), fg="black", bg="white") self.label3.grid(row=5, column=0, sticky=tk.W) # シークバーの表示 self.seekbarval2 = tk.DoubleVar() # シークバー変数設定 self.seekbarval2.trace("w", self.func_callback_seekbar) # シークバー変数変動時コールバック関数設定 self.sc = ttk.Scale(self, variable=self.seekbarval2, orient=tk.HORIZONTAL, from_=0, to=255) # シークバー描画 self.sc.grid(row=6, column=0, columnspan=2, sticky=(tk.N, tk.E, tk.S, tk.W)) # ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label4 = tk.Label(self, text='酸味', font=("Helvetica", 10, "normal"), fg="black", bg="white") self.label4.grid(row=7, column=0, sticky=tk.W) # シークバーの表示 self.seekbarval3 = tk.DoubleVar() # シークバー変数設定 self.seekbarval3.trace("w", self.func_callback_seekbar) # シークバー変数変動時コールバック関数設定 self.sc = ttk.Scale(self, variable=self.seekbarval3, orient=tk.HORIZONTAL, from_=0, to=255) # シークバー描画 self.sc.grid(row=8, column=0, columnspan=2, sticky=(tk.N, tk.E, tk.S, tk.W)) # ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label5 = tk.Label(self, text='苦味', font=("Helvetica", 10, "normal"), fg="black", bg="white") self.label5.grid(row=9, column=0, sticky=tk.W) # シークバーの表示 self.seekbarval4 = tk.DoubleVar() # シークバー変数設定 self.seekbarval4.trace("w", self.func_callback_seekbar) # シークバー変数変動時コールバック関数設定 self.sc = ttk.Scale(self, variable=self.seekbarval4, orient=tk.HORIZONTAL, from_=0, to=255) # シークバー描画 self.sc.grid(row=10, column=0, columnspan=2, sticky=(tk.N, tk.E, tk.S, tk.W)) # ラベル表示するテキストを設定 font(フォント名/サイズ/太文字),fg:文字色,bg:背景色 self.label6 = tk.Label(self, text='旨味', font=("Helvetica", 10, "normal"), fg="black", bg="white") self.label6.grid(row=11, column=0, sticky=tk.W) # シークバーの表示 self.seekbarval5 = tk.DoubleVar() # シークバー変数設定 self.seekbarval5.trace("w", self.func_callback_seekbar) # シークバー変数変動時コールバック関数設定 self.sc = ttk.Scale(self, variable=self.seekbarval5, orient=tk.HORIZONTAL, from_=0, to=255) # シークバー描画 self.sc.grid(row=12, column=0, columnspan=2, sticky=(tk.N, tk.E, tk.S, tk.W))
def __init__(self, parent, fields, settings, callbacks, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.settings = settings self.callbacks = callbacks # New for ch7 self.current_record = None # A dict to keep track of input widgets self.inputs = {} # Build the form self.record_label = ttk.Label() self.record_label.grid(row=0, column=0) # recordinfo section recordinfo = tk.LabelFrame(self, text="Record Information") # line 1 self.inputs['Date'] = w.LabelInput( recordinfo, "Date", field_spec=fields['Date'] ) self.inputs['Date'].grid(row=0, column=0) self.inputs['Time'] = w.LabelInput( recordinfo, "Time", field_spec=fields['Time'] ) self.inputs['Time'].grid(row=0, column=1) self.inputs['Technician'] = w.LabelInput( recordinfo, "Technician", field_spec=fields['Technician'] ) self.inputs['Technician'].grid(row=0, column=2) # line 2 self.inputs['Lab'] = w.LabelInput( recordinfo, "Lab", field_spec=fields['Lab'] ) self.inputs['Lab'].grid(row=1, column=0) self.inputs['Plot'] = w.LabelInput( recordinfo, "Plot", field_spec=fields['Plot'] ) self.inputs['Plot'].grid(row=1, column=1) self.inputs['Seed sample'] = w.LabelInput( recordinfo, "Seed sample", field_spec=fields['Seed sample'] ) self.inputs['Seed sample'].grid(row=1, column=2) recordinfo.grid(row=1, column=0, sticky="we") # Environment Data environmentinfo = tk.LabelFrame(self, text="Environment Data") self.inputs['Humidity'] = w.LabelInput( environmentinfo, "Humidity (g/m³)", field_spec=fields['Humidity'] ) self.inputs['Humidity'].grid(row=0, column=0) self.inputs['Light'] = w.LabelInput( environmentinfo, "Light (klx)", field_spec=fields['Light'] ) self.inputs['Light'].grid(row=0, column=1) self.inputs['Temperature'] = w.LabelInput( environmentinfo, "Temperature (°C)", field_spec=fields['Temperature'] ) self.inputs['Temperature'].grid(row=0, column=2) self.inputs['Equipment Fault'] = w.LabelInput( environmentinfo, "Equipment Fault", field_spec=fields['Equipment Fault'] ) self.inputs['Equipment Fault'].grid(row=1, column=0, columnspan=3) environmentinfo.grid(row=2, column=0, sticky="we") # Plant Data section plantinfo = tk.LabelFrame(self, text="Plant Data") self.inputs['Plants'] = w.LabelInput( plantinfo, "Plants", field_spec=fields['Plants'] ) self.inputs['Plants'].grid(row=0, column=0) self.inputs['Blossoms'] = w.LabelInput( plantinfo, "Blossoms", field_spec=fields['Blossoms'] ) self.inputs['Blossoms'].grid(row=0, column=1) self.inputs['Fruit'] = w.LabelInput( plantinfo, "Fruit", field_spec=fields['Fruit'] ) self.inputs['Fruit'].grid(row=0, column=2) # Height data # create variables to be updated for min/max height # they can be referenced for min/max variables min_height_var = tk.DoubleVar(value='-infinity') max_height_var = tk.DoubleVar(value='infinity') self.inputs['Min Height'] = w.LabelInput( plantinfo, "Min Height (cm)", field_spec=fields['Min Height'], input_args={"max_var": max_height_var, "focus_update_var": min_height_var} ) self.inputs['Min Height'].grid(row=1, column=0) self.inputs['Max Height'] = w.LabelInput( plantinfo, "Max Height (cm)", field_spec=fields['Max Height'], input_args={"min_var": min_height_var, "focus_update_var": max_height_var} ) self.inputs['Max Height'].grid(row=1, column=1) self.inputs['Median Height'] = w.LabelInput( plantinfo, "Median Height (cm)", field_spec=fields['Median Height'], input_args={"min_var": min_height_var, "max_var": max_height_var} ) self.inputs['Median Height'].grid(row=1, column=2) plantinfo.grid(row=3, column=0, sticky="we") # Notes section self.inputs['Notes'] = w.LabelInput( self, "Notes", field_spec=fields['Notes'], input_args={"width": 75, "height": 10} ) self.inputs['Notes'].grid(sticky="w", row=4, column=0) # The save button self.savebutton = ttk.Button( self, text="Save", command=self.callbacks["on_save"]) self.savebutton.grid(sticky="e", row=5, padx=10) # default the form self.reset()
def __init__(self, reference): super(Central, self).__init__() # Saving reference to gui self.reference = reference # Setting up widgets self.grid_columnconfigure(0, weight=1) w = reference.width h = reference.height self.devices = tk.StringVar(self) self.connection_state = tk.StringVar(self) self.connection_state.set("Inactive") self.b1t = tk.StringVar(self) self.b1t.set("Connect") self.b2t = tk.StringVar(self) self.b2t.set("Upload") self.mode = tk.StringVar(self) self.mode.set("AOO") self.l8t = tk.StringVar(self) self.l8t.set("Atrium") self.devices_list = [] self.devices_text = ['a'] print(self.devices_list) self.f1 = tk.Frame(self, height=reference.height, width=250, bg="grey").place(x=0, y=0) self.l1 = tk.Label(self, text="Pacemaker Menu").place(x=75, y=10) self.l2 = tk.Label(self, text="Devices").place(x=15, y=44) self.o1 = tk.OptionMenu(self, self.devices, *self.devices_text) self.devices_refresh() self.o1.place(anchor=tk.NE, x=235, y=40) self.b1 = tk.Button(self, textvariable=self.b1t, command=self.device_button, state=tk.DISABLED, width=30) self.b1.place(x=15, y=80) self.devices.trace('w', self.device_select) self.l3 = tk.Label(self, text="Connection Status").place(x=15, y=120) self.l4 = tk.Label(self, textvariable=self.connection_state).place(anchor=tk.NE, x=235, y=120) self.b2 = tk.Button(self, textvariable=self.b2t, command=self.device_upload, state=tk.DISABLED, width=30) self.b2.place(x=15, y=180) self.b3 = tk.Button(self, text="Refresh", command=self.devices_refresh, width=30) self.b3.place(x=15, y=210) self.l10 = tk.Label(self, text="Egram PlayBack").place(x=75, y=340) self.b4 = tk.Button(self, text="Play", command=self.device_play, width=9, state=tk.DISABLED) self.b4.place(x=15, y=370) self.b5 = tk.Button(self, text="Stop", command=self.device_stop, width=9, state=tk.DISABLED) self.b5.place(x=90, y=370) self.b6 = tk.Button(self, text="Clear", command=self.device_clear, width=9, state=tk.DISABLED) self.b6.place(x=165, y=370) # Pacemaker parameters self.t1 = tk.Label(self, text="Pacemaker Parameter").place(x=w/2+60, y=0) self.o2 = tk.OptionMenu(self, self.mode, "AOO", "VOO", "AAI", "VVI", "DOO", "AOOR", "VOOR", "AAIR", "VVIR", "DOOR").place(x=265, y=40) self.l7 = tk.Label(self, text="Affected Chamber: ").place(x=355, y=46) self.l8 = tk.Label(self, textvariable=self.l8t).place(x=460, y=46) self.mode.trace('w', self.mode_select) rx = 265 ry = 76 rinc = 170 self.s1v = tk.DoubleVar() self.s1 = tk.Scale(self, orient=tk.HORIZONTAL, variable=self.s1v, length=150, from_=0.1, to=1.9, resolution=0.1) self.s1.place(x=rx, y=ry) self.s1v.set(0.4) self.s1t = tk.Label(self, text="Pulse Width (ms)").place(x=rx+20, y=ry+40) rx += rinc self.s2v = tk.DoubleVar() self.s2 = tk.Scale(self, orient=tk.HORIZONTAL, variable=self.s2v, length=150, from_=500, to=7500, resolution=50) self.s2.place(x=rx, y=ry) self.s2v.set(3750) self.s2t = tk.Label(self, text="Pulse Amplitude (mV)").place(x=rx+20, y=ry+40) rx += rinc self.s3v = tk.DoubleVar() self.s3 = tk.Scale(self, orient=tk.HORIZONTAL, variable=self.s3v, length=150, from_=30, to=175, resolution=1) self.s3.place(x=rx, y=ry) self.s3v.set(60) self.s3t = tk.Label(self, text="Lower Limit (ppm)").place(x=rx+20, y=ry+40) self.s5v = tk.DoubleVar() self.s5 = tk.Scale(self, orient=tk.HORIZONTAL, variable=self.s5v, length=150, from_=120, to=300, resolution=1) self.s5.place(x=rx, y=ry+70) self.s5v.set(200) self.s5t = tk.Label(self, text="Upper Limit (ppm)").place(x=rx+20, y=ry+110) rx += rinc self.s4v = tk.DoubleVar() self.s4 = tk.Scale(self, orient=tk.HORIZONTAL, variable=self.s4v, length=150, from_=150, to=500, resolution=5) self.s4.place(x=rx, y=ry) self.s4v.set(250) self.s4t = tk.Label(self, text="Refractory Period (ms)").place(x=rx+20, y=ry+40) # Create Graphs canvasHeight = 300 canvasWidth = 500 self.c1 = Graph(reference=reference, canv_h=canvasHeight,canv_w=canvasWidth, name="Atrium EGram") self.c1.place(x=-2, y=398) self.c2 = Graph(reference=reference, canv_h=canvasHeight, canv_w=canvasWidth, name="Ventricle EGram") self.c2.place(x=500, y=398) self.reference.coms.set_atr_graph(self.c1) self.reference.coms.set_vent_graph(self.c2) self.pack(expand=1, fill=tk.BOTH)
def __init__(self, parent): ''' Constructed function, initiate arguments and UI. ''' super().__init__() self.title('Settings') self.parent = parent # the parent window self.window_size = [100, 100] self.stride = 25 self.geometry('450x250') self.resizable(False, False) # the "Scale" row Scale_frame = tk.Frame(self) Scale_frame.pack(fill="x") tk.Label(Scale_frame, text='Scale (200 for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Scale = tk.IntVar(value=200) tk.Entry(Scale_frame, textvariable=self.Scale, width=8).pack(side=tk.LEFT) # the "Sigma" row Sigma_frame = tk.Frame(self) Sigma_frame.pack(fill="x") tk.Label(Sigma_frame, text='Sigma (0.6 for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Sigma = tk.DoubleVar(value=0.6) tk.Entry(Sigma_frame, textvariable=self.Sigma, width=8).pack(side=tk.LEFT) # the "Min_size" row Min_size_frame = tk.Frame(self) Min_size_frame.pack(fill="x") tk.Label(Min_size_frame, text='Min_size (80 for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Min_size = tk.IntVar(value=80) tk.Entry(Min_size_frame, textvariable=self.Min_size, width=8).pack(side=tk.LEFT) # the "Min_elongation" row Min_elongation_frame = tk.Frame(self) Min_elongation_frame.pack(fill="x") tk.Label(Min_elongation_frame, text='Min_elongation (0.5 for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Min_elongation = tk.DoubleVar(value=0.5) tk.Entry(Min_elongation_frame, textvariable=self.Min_elongation, width=8).pack(side=tk.LEFT) # the "Maximum_box" row Maximum_box_frame = tk.Frame(self) Maximum_box_frame.pack(fill="x") tk.Label(Maximum_box_frame, text='Maxsize of bounding box (10000 pixels for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Maximum_box = tk.IntVar(value=10000) tk.Entry(Maximum_box_frame, textvariable=self.Maximum_box, width=8).pack(side=tk.LEFT) # the "Minimum_box" row Minimum_box_frame = tk.Frame(self) Minimum_box_frame.pack(fill="x") tk.Label(Minimum_box_frame, text='Minsize of bounding box (100 pixels for default) :', width=40, font=('Times New Roman', 12)).pack(side=tk.LEFT) self.Minimum_box = tk.IntVar(value=100) tk.Entry(Minimum_box_frame, textvariable=self.Minimum_box, width=8).pack(side=tk.LEFT) # the button row self.button_frame = tk.Frame(self) self.button_frame.pack(fill="x", pady=10) tk.Button(self.button_frame, text="Cancel", command=self.cancel, relief='raised', font=('Times New Roman', 12)).pack(side=tk.RIGHT, padx=20) tk.Button(self.button_frame, text="Confirm", command=self.ok, relief='raised', font=('Times New Roman', 12)).pack(side=tk.LEFT, padx=20) # the warning label self.warning_label = tk.Label( self, text='Please input the desired windowsize', width=45, height=20, font=('Times New Roman', 10)) self.warning_label.pack(pady=5, fill='x')