Salut à tous !
Je suis en train de dev un petit logiciel en python + PySide,
Voici un screen de manière à illustrer mes propos
Voici mon interface actuelle.
Afin de répondre au besoin utilisateur je doit avoir une interface du type :
Mon problème est le suivant, afin de m'éviter du code (surtout du code pas propre), j'aimerais essayer de gérer mes composants de manière à ne pas faire une méthode pour chacun
Aujourd'hui mon code pour remplir mes elements est le suivant :
j'aimerais faire en sorte de ne pas avoir une méthode pour chaque composant.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 def set_combobox_db(self): """ Method to set elements into the combobox db """ try: process_db = processing_db_access_conf() path_file = process_db.get_one_conf_path() c_process = Processing(path_file) bases = c_process.get_all_db() self.comboBox.clear() for base in bases: self.comboBox.addItem(base) except: pass def set_combobox_element(self): """ Method to set elements into the combobox element """ try: process_db = processing_db_access_conf() path_file = process_db.get_one_conf_path() c_process = Processing(path_file) get_text_cb_db = str(self.comboBox.currentText()) bases = c_process.get_data_all(get_text_cb_db) self.comboBox_2.clear() for base in bases: self.comboBox_2.addItem(base) except: pass
idem pour ma méthode d'envoi :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 def cmd_set(self): #run the timer self.create_timer() #Connect the signal self.connect_signal() #Run the thread self.com_monitor_thread.start() process_db = processing_db_access_conf() path_file = process_db.get_one_conf_path() c_processing = Processing(path_file) list_to_prepare =[] text_db = self.comboBox.currentText() text_element = self.comboBox_2.currentText() text_value = self.lineEdit.text() value_to_send = c_processing.get_values(text_value) list_cmd = ['DRV_COM_COMMANDS','CMD_SET'] #get the encoded data data = self.get_data_to_send(list_cmd) list_without_lenght = [data[0],data[1],data[2],value_to_send[0],value_to_send[1]] c_processing_json_file = processing_db_access_conf() data_json = c_processing_json_file.open_json_file_read() com_port =data_json["com"]["port_com"] self.connection.connect(com_port) #Check if thread is ready to read the serial port self.is_ready_to_read() #Send data self.connection.send_message(list_without_lenght) self.connection.close_connection()
Quelqu'un a t'il une méthode a me conseiller ?
J'ai essayer de chercher mais je n'arrive pas a formuler ma recherche correctement
Merci d'avance
Partager