Module ihm_pyxmaker
[hide private]
[frames] | no frames]

Source Code for Module ihm_pyxmaker

   1  #!/usr/bin/env python 
   2  #-*- coding:utf-8 -* 
   3   
   4   
   5  """ 
   6          Manage the pyxmaker IHM 
   7           
   8          G{importgraph} 
   9  """ 
  10   
  11   
  12  #       Pyxmaker 
  13  #       Copyright (C) 2013 GALODE A. 
  14  # 
  15  #       This file is part of Expymaker. 
  16  #  
  17  #       Pyxmaker is free software: you can redistribute it and/or modify 
  18  #       it under the terms of the GNU General Public License as published by 
  19  #       the Free Software Foundation, either version 3 of the License, or 
  20  #       (at your option) any later version. 
  21  #  
  22  #       Pyxmaker is distributed in the hope that it will be useful, 
  23  #       but WITHOUT ANY WARRANTY; without even the implied warranty of 
  24  #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  25  #       GNU General Public License for more details. 
  26  # 
  27  #       You should have received a copy of the GNU General Public License 
  28  #       along with Pyxmaker.  If not, see <http://www.gnu.org/licenses/> 
  29   
  30   
  31  #import pygtk 
  32  #import gtk 
  33  import os 
  34  import sys 
  35  import uuid 
  36  import time 
  37  import re 
  38   
  39   
  40   
  41   
  42  #=======================================================================# 
  43  #                                               Classe gérant l'IHM                                                            # 
  44  #=======================================================================# 
45 -class IhmPyxmaker():
46 """ 47 Class which manage the PYGTK IHM 48 49 G{classtree} 50 """ 51 52
53 - def __init__(self, listing_menu, listing_lang, dict_config, dict_about, path_base, \ 54 fct_p_config_save, fct_config_open, fct_lang_change, fct_gener_setup):
55 self.listing_menu = listing_menu 56 self.listing_lang = listing_lang 57 self.dict_config = dict_config 58 self.dict_about = dict_about 59 self.path_base = path_base 60 self.fct_p_config_save = fct_p_config_save 61 self.fct_config_open = fct_config_open 62 self.fct_lang_change = fct_lang_change 63 self.fct_gener_setup = fct_gener_setup 64 65 self.scr_idx = 0 66 67 self.scr_alim() 68 self.scr_exe() 69 self.scr_info() 70 self.scr_param() 71 self.scr_base() 72 73 self.p_lang_alim() 74 75 x1, y1 = self.scr_exe_vbox.size_request() 76 x2, y2 = self.scr_info_vbox.size_request() 77 x3, y3 = self.scr_param_table.size_request() 78 x4, y4 = self.scr_base_win.size_request() 79 x5, y5 = self.scr_base_win_hbox.size_request() 80 self.x = max([x1,x2,x3,x4,x5]) + 50 81 self.y = max([y1,y2,y3,y4,y5]) 82 self.scr_exe_vbox.set_size_request(self.x, self.y) 83 self.scr_info_vbox.set_size_request(self.x, self.y) 84 self.scr_param_table.set_size_request(self.x, self.y) 85 self.scr_base_win.set_size_request(self.x, self.y + y5) 86 self.scr_base_win_hbox.set_size_request(self.x, y5)
87 88 89 90 91 #===================================================# 92 # Procedure permettant de lancer l'IHM # 93 #===================================================#
94 - def start_ihm(self):
95 """ 96 Allow to launch the HMI 97 98 PARAMETERS 99 ========== 100 None 101 102 RETURNS 103 ======= 104 None 105 """ 106 gtk.main()
107 108 109 110 111 #===================================================# 112 # Fenetre de l'appli # 113 #===================================================#
114 - def scr_base(self):
115 """ 116 Main window 117 118 PARAMETERS 119 ========== 120 None 121 122 RETURNS 123 ======= 124 None 125 """ 126 self.scr_base_win = gtk.Window() 127 self.scr_base_win.set_title(self.scr_all_text_title) 128 129 self.scr_base_win_tab_main = gtk.Table(rows=2, columns=1, homogeneous=False) 130 self.scr_base_win_hbox = gtk.HBox(homogeneous=False, spacing=2) 131 132 self.scr_base_win_label_title = gtk.Label() 133 self.scr_title(self.scr_info_text_title) 134 135 self.scr_base_win_button_previous = gtk.Button() 136 self.scr_base_win_button_previous.connect("clicked", self.scr_change_previous) 137 self.scr_base_win_button_im_previous = gtk.Image() 138 path_previous = os.path.join(self.path_base,"02-IMG/previous.png") 139 self.scr_base_win_button_im_previous.set_from_file(path_previous) 140 self.scr_base_win_button_previous.add(self.scr_base_win_button_im_previous) 141 142 self.scr_base_win_button_next = gtk.Button() 143 self.scr_base_win_button_next.connect("clicked", self.scr_change_next) 144 self.scr_base_win_button_im_next = gtk.Image() 145 path_next = os.path.join(self.path_base,"02-IMG/next.png") 146 self.scr_base_win_button_im_next.set_from_file(path_next) 147 self.scr_base_win_button_next.add(self.scr_base_win_button_im_next) 148 149 self.scr_base_win_hbox.pack_start(self.scr_base_win_button_previous, expand=False, fill=True, padding=2) 150 self.scr_base_win_hbox.pack_start(self.scr_base_win_label_title, expand=True, fill=True, padding=2) 151 self.scr_base_win_hbox.pack_start(self.scr_base_win_button_next, expand=False, fill=False, padding=2) 152 153 self.scr_base_win_tab_main.attach(self.scr_base_win_hbox,0,1,0,1,gtk.EXPAND|gtk.FILL,gtk.SHRINK|gtk.FILL) 154 self.scr_base_win_tab_main.attach(self.scr_param_table,0,1,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL) 155 self.scr_base_win_tab_main.attach(self.scr_info_vbox,0,1,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL) 156 self.scr_base_win_tab_main.attach(self.scr_exe_vbox,0,1,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL) 157 self.scr_base_win.add(self.scr_base_win_tab_main) 158 self.scr_base_win.connect("destroy", gtk.main_quit) 159 160 self.scr_base_win_button_previous.set_sensitive(False) 161 self.scr_base_win_button_next.set_sensitive(True) 162 163 self.scr_base_win_button_im_previous.show() 164 self.scr_base_win_button_im_next.show() 165 self.scr_base_win_hbox.show() 166 self.scr_base_win_label_title.show() 167 self.scr_base_win_button_previous.show() 168 self.scr_base_win_button_next.show() 169 self.scr_base_win_tab_main.show() 170 self.scr_base_win.show()
171 172 173 174 175 #===================================================# 176 # Procedure gerant l'affichage du titre de l'ecran # 177 #===================================================#
178 - def scr_title(self, texte):
179 """ 180 Manage the screen title display 181 182 PARAMETERS 183 ========== 184 texte 185 ----- 186 The text to display 187 188 RETURNS 189 ======= 190 None 191 """ 192 width = 60 193 qty = (width - len(texte)) / 2 194 195 texte = texte.ljust(qty + len(texte)) 196 texte = texte.rjust(width) 197 198 title_text = "<b><big><span size=\"xx-large\" foreground=\"white\" background=\"#1E7FCB\">" + \ 199 texte + "</span></big></b>" 200 self.scr_base_win_label_title.set_text(title_text) 201 self.scr_base_win_label_title.set_width_chars(width) 202 self.scr_base_win_label_title.set_use_markup(True)
203 204 205 206 207 #===================================================# 208 # Procedure alimentant les menus # 209 #===================================================#
210 - def scr_alim(self):
211 """ 212 Allow to supply the menus 213 214 PARAMETERS 215 ========== 216 None 217 218 RETURNS 219 ======= 220 None 221 """ 222 for i in range(0, len(self.listing_menu)): 223 if self.listing_menu[i][0] == "INFO": 224 if self.listing_menu[i][1] == "REQUIRED": 225 self.scr_info_text_required = self.listing_menu[i][2] 226 elif self.listing_menu[i][1] == "NAME": 227 self.scr_info_text_name = self.listing_menu[i][2] 228 elif self.listing_menu[i][1] == "VERSION": 229 self.scr_info_text_version = self.listing_menu[i][2] 230 elif self.listing_menu[i][1] == "AUTHOR": 231 self.scr_info_text_author = self.listing_menu[i][2] 232 elif self.listing_menu[i][1] == "AUTHOR_MAIL": 233 self.scr_info_text_author_mail = self.listing_menu[i][2] 234 elif self.listing_menu[i][1] == "MAINTAINER": 235 self.scr_info_text_maintenor = self.listing_menu[i][2] 236 elif self.listing_menu[i][1] == "MAINTAINER_MAIL": 237 self.scr_info_text_maintenor_mail = self.listing_menu[i][2] 238 elif self.listing_menu[i][1] == "FAST_DESCRIPTION": 239 self.scr_info_text_fast_description = self.listing_menu[i][2] 240 elif self.listing_menu[i][1] == "WEBSITE": 241 self.scr_info_text_website = self.listing_menu[i][2] 242 elif self.listing_menu[i][1] == "TITLE": 243 self.scr_info_text_title = self.listing_menu[i][2] 244 elif self.listing_menu[i][1] == "WINCONS": 245 self.scr_info_text_wincons = self.listing_menu[i][2] 246 elif self.listing_menu[i][1] == "WINCONS_TT": 247 self.scr_info_tt_wincons = self.listing_menu[i][2] 248 elif self.listing_menu[i][1] == "NAME_TT": 249 self.scr_info_tt_name = self.listing_menu[i][2] 250 elif self.listing_menu[i][1] == "VERSION_TT": 251 self.scr_info_tt_version = self.listing_menu[i][2] 252 elif self.listing_menu[i][1] == "AUTHOR_TT": 253 self.scr_info_tt_author = self.listing_menu[i][2] 254 elif self.listing_menu[i][1] == "AUTHOR_MAIL_TT": 255 self.scr_info_tt_author_mail = self.listing_menu[i][2] 256 elif self.listing_menu[i][1] == "MAINTAINER_TT": 257 self.scr_info_tt_maintainer = self.listing_menu[i][2] 258 elif self.listing_menu[i][1] == "MAINTAINER_MAIL_TT": 259 self.scr_info_tt_maintainer_mail = self.listing_menu[i][2] 260 elif self.listing_menu[i][1] == "FAST_DESCRIPTION_TT": 261 self.scr_info_tt_fast_description = self.listing_menu[i][2] 262 elif self.listing_menu[i][1] == "WEBSITE_TT": 263 self.scr_info_tt_website = self.listing_menu[i][2] 264 265 266 elif self.listing_menu[i][0] == "EXE": 267 if self.listing_menu[i][1] == "TITLE": 268 self.scr_exe_text_title = self.listing_menu[i][2] 269 elif self.listing_menu[i][1] == "PJ_DIR": 270 self.scr_exe_text_pj_dir = self.listing_menu[i][2] 271 elif self.listing_menu[i][1] == "PY_EXE": 272 self.scr_exe_text_py_exe = self.listing_menu[i][2] 273 elif self.listing_menu[i][1] == "SETUP": 274 self.scr_exe_text_setup = self.listing_menu[i][2] 275 elif self.listing_menu[i][1] == "SETUP_MENU_NAME": 276 self.scr_exe_text_setup_menu_name = self.listing_menu[i][2] 277 elif self.listing_menu[i][1] == "SETUP_NAME": 278 self.scr_exe_text_setup_name = self.listing_menu[i][2] 279 elif self.listing_menu[i][1] == "SETUP_ICON": 280 self.scr_exe_text_setup_icon = self.listing_menu[i][2] 281 elif self.listing_menu[i][1] == "SETUP_PASSWD": 282 self.scr_exe_text_setup_passwd = self.listing_menu[i][2] 283 elif self.listing_menu[i][1] == "SETUP_CREATION": 284 self.scr_exe_text_setup_creation = self.listing_menu[i][2] 285 elif self.listing_menu[i][1] == "PJ_DIR_TT": 286 self.scr_info_tt_pj_dir = self.listing_menu[i][2] 287 elif self.listing_menu[i][1] == "PY_EXE_TT": 288 self.scr_info_tt_py_exe = self.listing_menu[i][2] 289 elif self.listing_menu[i][1] == "SETUP_MENU_NAME_TT": 290 self.scr_info_tt_setup_menu_name = self.listing_menu[i][2] 291 elif self.listing_menu[i][1] == "SETUP_NAME_TT": 292 self.scr_info_tt_setup_name = self.listing_menu[i][2] 293 elif self.listing_menu[i][1] == "SETUP_ICON_TT": 294 self.scr_info_tt_setup_icon = self.listing_menu[i][2] 295 elif self.listing_menu[i][1] == "SETUP_PASSWD_TT": 296 self.scr_info_tt_setup_passwd = self.listing_menu[i][2] 297 elif self.listing_menu[i][1] == "SETUP_CREATION_TT": 298 self.scr_info_tt_setup_creation = self.listing_menu[i][2] 299 300 301 elif self.listing_menu[i][0] == "PARAM": 302 if self.listing_menu[i][1] == "LANG": 303 self.scr_param_text_lang = self.listing_menu[i][2] 304 elif self.listing_menu[i][1] == "OPEN": 305 self.scr_param_text_open = self.listing_menu[i][2] 306 elif self.listing_menu[i][1] == "SAVE": 307 self.scr_param_text_save = self.listing_menu[i][2] 308 elif self.listing_menu[i][1] == "ABOUT": 309 self.scr_param_text_about = self.listing_menu[i][2] 310 elif self.listing_menu[i][1] == "EXIT": 311 self.scr_param_text_exit = self.listing_menu[i][2] 312 elif self.listing_menu[i][1] == "TITLE": 313 self.scr_param_text_title = self.listing_menu[i][2] 314 elif self.listing_menu[i][1] == "DOC": 315 self.scr_param_text_doc = self.listing_menu[i][2] 316 elif self.listing_menu[i][1] == "LANG_TT": 317 self.scr_info_tt_lang = self.listing_menu[i][2] 318 elif self.listing_menu[i][1] == "OPEN_TT": 319 self.scr_info_tt_open = self.listing_menu[i][2] 320 elif self.listing_menu[i][1] == "SAVE_TT": 321 self.scr_info_tt_save = self.listing_menu[i][2] 322 elif self.listing_menu[i][1] == "ABOUT_TT": 323 self.scr_info_tt_about = self.listing_menu[i][2] 324 elif self.listing_menu[i][1] == "EXIT_TT": 325 self.scr_info_tt_exit = self.listing_menu[i][2] 326 elif self.listing_menu[i][1] == "DOC_TT": 327 self.scr_info_tt_doc = self.listing_menu[i][2] 328 329 330 elif self.listing_menu[i][0] == "ALL": 331 if self.listing_menu[i][1] == "NEXT": 332 self.scr_all_text_next = self.listing_menu[i][2] 333 elif self.listing_menu[i][1] == "PREVIOUS": 334 self.scr_all_text_previous = self.listing_menu[i][2] 335 elif self.listing_menu[i][1] == "TITLE": 336 self.scr_all_text_title = self.listing_menu[i][2] 337 elif self.listing_menu[i][1] == "EMPTY_FIELDS": 338 self.scr_all_text_fields = self.listing_menu[i][2] 339 elif self.listing_menu[i][1] == "PATH_ERROR": 340 self.scr_all_text_path_error = self.listing_menu[i][2] 341 elif self.listing_menu[i][1] == "GENERATION_OK": 342 self.scr_all_text_gener_ok = self.listing_menu[i][2] 343 elif self.listing_menu[i][1] == "GENERATION_KO": 344 self.scr_all_text_gener_ko = self.listing_menu[i][2] 345 elif self.listing_menu[i][1] == "GENERATION_OKO": 346 self.scr_all_text_gener_oko = self.listing_menu[i][2] 347 elif self.listing_menu[i][1] == "WAIT": 348 self.scr_all_text_wait = self.listing_menu[i][2]
349 350 351 352 353 #===================================================# 354 # Ecran Information de l'appli # 355 #===================================================#
356 - def scr_info(self):
357 """ 358 The information screen 359 360 PARAMETERS 361 ========== 362 None 363 364 RETURNS 365 ======= 366 None 367 """ 368 self.scr_info_vbox = gtk.VBox() 369 370 self.scr_info_frame = gtk.Frame(label = self.scr_info_text_required) 371 self.scr_info_tab_main = gtk.Table(rows=5, columns=4, homogeneous=False) 372 373 self.scr_info_label_name = gtk.Label(self.scr_info_text_name) 374 self.scr_info_label_version = gtk.Label(self.scr_info_text_version) 375 self.scr_info_label_author = gtk.Label(self.scr_info_text_author) 376 self.scr_info_label_author_mail = gtk.Label(self.scr_info_text_author_mail) 377 self.scr_info_label_maintenor = gtk.Label(self.scr_info_text_maintenor) 378 self.scr_info_label_maintenor_mail = gtk.Label(self.scr_info_text_maintenor_mail) 379 self.scr_info_label_fast_description = gtk.Label(self.scr_info_text_fast_description) 380 self.scr_info_label_website = gtk.Label(self.scr_info_text_website) 381 382 self.mode_wincons = gtk.CheckButton(self.scr_info_text_wincons) 383 self.mode_wincons.set_active(True) 384 385 self.scr_info_entry_name = gtk.Entry() 386 self.scr_info_entry_version = gtk.Entry() 387 self.scr_info_entry_author = gtk.Entry() 388 self.scr_info_entry_author_mail = gtk.Entry() 389 self.scr_info_entry_maintenor = gtk.Entry() 390 self.scr_info_entry_maintenor_mail = gtk.Entry() 391 self.scr_info_entry_fast_description = gtk.Entry() 392 self.scr_info_entry_website = gtk.Entry() 393 394 self.scr_info_entry_tt_name = gtk.Tooltips() 395 self.scr_info_entry_tt_version = gtk.Tooltips() 396 self.scr_info_entry_tt_author = gtk.Tooltips() 397 self.scr_info_entry_tt_author_mail = gtk.Tooltips() 398 self.scr_info_entry_tt_maintainer = gtk.Tooltips() 399 self.scr_info_entry_tt_maintainer_mail = gtk.Tooltips() 400 self.scr_info_entry_tt_fast_description = gtk.Tooltips() 401 self.scr_info_entry_tt_website = gtk.Tooltips() 402 self.scr_info_checkb_tt_name = gtk.Tooltips() 403 404 self.scr_info_entry_tt_name.set_tip(self.scr_info_entry_name, self.scr_info_tt_name, None) 405 self.scr_info_entry_tt_version.set_tip(self.scr_info_entry_version, self.scr_info_tt_version, None) 406 self.scr_info_entry_tt_author.set_tip(self.scr_info_entry_author, self.scr_info_tt_author, None) 407 self.scr_info_entry_tt_author_mail.set_tip(self.scr_info_entry_author_mail, self.scr_info_tt_author_mail, None) 408 self.scr_info_entry_tt_maintainer.set_tip(self.scr_info_entry_maintenor, self.scr_info_tt_maintainer, None) 409 self.scr_info_entry_tt_maintainer_mail.set_tip(self.scr_info_entry_maintenor_mail, self.scr_info_tt_maintainer_mail, None) 410 self.scr_info_entry_tt_fast_description.set_tip(self.scr_info_entry_fast_description, self.scr_info_tt_fast_description, None) 411 self.scr_info_entry_tt_website.set_tip(self.scr_info_entry_website, self.scr_info_tt_website, None) 412 self.scr_info_checkb_tt_name.set_tip(self.mode_wincons, self.scr_info_tt_wincons, None) 413 414 self.scr_info_tab_main.attach(self.scr_info_label_name,0,1,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 415 self.scr_info_tab_main.attach(self.scr_info_label_version,2,3,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 416 self.scr_info_tab_main.attach(self.scr_info_label_author,0,1,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 417 self.scr_info_tab_main.attach(self.scr_info_label_author_mail,2,3,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 418 self.scr_info_tab_main.attach(self.scr_info_label_maintenor,0,1,2,3,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 419 self.scr_info_tab_main.attach(self.scr_info_label_maintenor_mail,2,3,2,3,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 420 self.scr_info_tab_main.attach(self.scr_info_label_fast_description,0,1,3,4,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 421 self.scr_info_tab_main.attach(self.scr_info_label_website,0,1,4,5,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 422 423 self.scr_info_tab_main.attach(self.scr_info_entry_name,1,2,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 424 self.scr_info_tab_main.attach(self.scr_info_entry_version,3,4,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 425 self.scr_info_tab_main.attach(self.scr_info_entry_author,1,2,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 426 self.scr_info_tab_main.attach(self.scr_info_entry_author_mail,3,4,1,2,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 427 self.scr_info_tab_main.attach(self.scr_info_entry_maintenor,1,2,2,3,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 428 self.scr_info_tab_main.attach(self.scr_info_entry_maintenor_mail,3,4,2,3,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 429 self.scr_info_tab_main.attach(self.scr_info_entry_fast_description,1,4,3,4,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 430 self.scr_info_tab_main.attach(self.scr_info_entry_website,1,4,4,5,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL,xpadding=2,ypadding=2) 431 432 self.scr_info_frame.add(self.scr_info_tab_main) 433 self.scr_info_vbox.pack_start(self.scr_info_frame, expand = False, fill = True, padding = 2) 434 self.scr_info_vbox.pack_start(self.mode_wincons, expand = False, fill = True, padding = 2) 435 436 self.scr_info_label_name.show() 437 self.scr_info_label_version.show() 438 self.scr_info_label_author.show() 439 self.scr_info_label_author_mail.show() 440 self.scr_info_label_maintenor.show() 441 self.scr_info_label_maintenor_mail.show() 442 self.scr_info_label_fast_description.show() 443 self.scr_info_label_website.show() 444 445 self.scr_info_entry_name.show() 446 self.scr_info_entry_version.show() 447 self.scr_info_entry_author.show() 448 self.scr_info_entry_author_mail.show() 449 self.scr_info_entry_maintenor.show() 450 self.scr_info_entry_maintenor_mail.show() 451 self.scr_info_entry_fast_description.show() 452 self.scr_info_entry_website.show() 453 454 self.mode_wincons.show() 455 456 self.scr_info_tab_main.show() 457 self.scr_info_frame.show() 458 459 self.scr_info_vbox.show()
460 461 462 463 464 #===================================================# 465 # Ecran executable de l'appli # 466 #===================================================#
467 - def scr_exe(self):
468 """ 469 The executable screen 470 471 PARAMETERS 472 ========== 473 None 474 475 RETURNS 476 ======= 477 None 478 """ 479 self.scr_exe_vbox = gtk.VBox(False, 2) 480 self.scr_exe_setup_vbox_left = gtk.VBox(True,4) 481 self.scr_exe_setup_vbox_right = gtk.VBox(True,4) 482 self.scr_exe_setup_hbox = gtk.HBox(False,4) 483 self.scr_exe_pj_hbox = gtk.HBox(False,2) 484 self.scr_exe_button_creation_hbox = gtk.HBox(False,2) 485 self.scr_exe_button_creation_hbox2 = gtk.HBox(False,2) 486 self.scr_exe_hbox_setup_icon = gtk.HBox(False,2) 487 488 self.scr_exe_cbox_executable = gtk.combo_box_new_text() 489 490 self.scr_exe_frame_pj = gtk.Frame(label = self.scr_exe_text_pj_dir) 491 self.scr_exe_frame_executable = gtk.Frame(label = self.scr_exe_text_py_exe) 492 self.scr_exe_frame_setup = gtk.Frame(label = self.scr_exe_text_setup) 493 494 self.scr_exe_label_button_creation = gtk.Label("<b>" + self.scr_exe_text_setup_creation + "</b>") 495 self.scr_exe_label_button_creation.set_use_markup(True) 496 self.scr_exe_label_menu_name = gtk.Label(self.scr_exe_text_setup_menu_name) 497 self.scr_exe_label_setup_name = gtk.Label(self.scr_exe_text_setup_name) 498 self.scr_exe_label_setup_icon = gtk.Label(self.scr_exe_text_setup_icon) 499 self.scr_exe_label_setup_passwd = gtk.Label(self.scr_exe_text_setup_passwd) 500 501 502 self.scr_exe_entry_pj = gtk.Entry() 503 self.scr_exe_entry_setup_name = gtk.Entry() 504 self.scr_exe_entry_setup_icon = gtk.Entry() 505 self.scr_exe_entry_setup_passwd = gtk.Entry() 506 507 self.scr_exe_button_creation = gtk.Button() 508 self.scr_exe_button_creation.connect("clicked", self.p_generate_global) 509 self.scr_exe_button_im_creation = gtk.Image() 510 path_previous = os.path.join(self.path_base,"02-IMG/go_exe.png") 511 self.scr_exe_button_im_creation.set_from_file(path_previous) 512 self.scr_exe_button_creation_hbox.pack_start(self.scr_exe_button_im_creation, expand=False, fill=False, padding=2) 513 self.scr_exe_button_creation_hbox.pack_start(self.scr_exe_label_button_creation, expand=False, fill=False, padding=2) 514 self.scr_exe_button_creation.add(self.scr_exe_button_creation_hbox) 515 self.scr_exe_button_creation_hbox2.pack_start(self.scr_exe_button_creation, expand=True, fill=False, padding=2) 516 517 self.scr_exe_button_pj = gtk.Button() 518 self.scr_exe_button_pj.connect("clicked", self.p_select_dir_pj) 519 self.scr_exe_button_im_pj = gtk.Image() 520 path_pj = os.path.join(self.path_base,"02-IMG/folder.png") 521 self.scr_exe_button_im_pj.set_from_file(path_pj) 522 self.scr_exe_button_pj.add(self.scr_exe_button_im_pj) 523 524 self.scr_exe_button_setup_icon = gtk.Button() 525 self.scr_exe_button_setup_icon.connect("clicked", self.p_select_setup_icon) 526 self.scr_exe_button_im_setup_icon = gtk.Image() 527 path_setp_icon = os.path.join(self.path_base,"02-IMG/load.png") 528 self.scr_exe_button_im_setup_icon.set_from_file(path_setp_icon) 529 self.scr_exe_button_setup_icon.add(self.scr_exe_button_im_setup_icon) 530 531 self.scr_exe_entry_tt_pj = gtk.Tooltips() 532 self.scr_exe_entry_tt_setup_name = gtk.Tooltips() 533 self.scr_exe_entry_tt_setup_icon = gtk.Tooltips() 534 self.scr_exe_entry_tt_setup_passwd = gtk.Tooltips() 535 self.scr_exe_cbox_tt_executable = gtk.Tooltips() 536 self.scr_exe_button_tt_creation = gtk.Tooltips() 537 538 self.scr_exe_entry_tt_pj.set_tip(self.scr_exe_entry_pj, self.scr_info_tt_pj_dir, None) 539 self.scr_exe_entry_tt_setup_name.set_tip(self.scr_exe_entry_setup_name, self.scr_info_tt_setup_name, None) 540 self.scr_exe_entry_tt_setup_icon.set_tip(self.scr_exe_entry_setup_icon, self.scr_info_tt_setup_icon, None) 541 self.scr_exe_entry_tt_setup_passwd.set_tip(self.scr_exe_entry_setup_passwd, self.scr_info_tt_setup_passwd, None) 542 self.scr_exe_cbox_tt_executable.set_tip(self.scr_exe_cbox_executable, self.scr_info_tt_py_exe, None) 543 self.scr_exe_button_tt_creation.set_tip(self.scr_exe_button_creation, self.scr_info_tt_setup_creation, None) 544 545 self.scr_exe_pj_hbox.pack_start(self.scr_exe_entry_pj) 546 self.scr_exe_pj_hbox.pack_start(self.scr_exe_button_pj, expand=False, fill=False) 547 self.scr_exe_frame_pj.add(self.scr_exe_pj_hbox) 548 549 self.scr_exe_setup_vbox_left.pack_start(self.scr_exe_label_setup_name) 550 self.scr_exe_setup_vbox_left.pack_start(self.scr_exe_label_setup_icon) 551 self.scr_exe_setup_vbox_left.pack_start(self.scr_exe_label_setup_passwd) 552 553 self.scr_exe_hbox_setup_icon.pack_start(self.scr_exe_entry_setup_icon) 554 self.scr_exe_hbox_setup_icon.pack_start(self.scr_exe_button_setup_icon, expand=False, fill=False) 555 556 self.scr_exe_setup_vbox_right.pack_start(self.scr_exe_entry_setup_name) 557 self.scr_exe_setup_vbox_right.pack_start(self.scr_exe_hbox_setup_icon) 558 self.scr_exe_setup_vbox_right.pack_start(self.scr_exe_entry_setup_passwd) 559 560 self.scr_exe_setup_hbox.pack_start(self.scr_exe_setup_vbox_left, expand=False, fill=False) 561 self.scr_exe_setup_hbox.pack_start(self.scr_exe_setup_vbox_right) 562 563 self.scr_exe_frame_setup.add(self.scr_exe_setup_hbox) 564 self.scr_exe_frame_executable.add(self.scr_exe_cbox_executable) 565 566 self.scr_exe_vbox.pack_start(self.scr_exe_frame_pj) 567 self.scr_exe_vbox.pack_start(self.scr_exe_frame_executable) 568 self.scr_exe_vbox.pack_start(self.scr_exe_frame_setup) 569 self.scr_exe_vbox.pack_start(self.scr_exe_button_creation_hbox2, expand=True, fill=True, padding=2) 570 571 self.scr_exe_button_pj.show() 572 self.scr_exe_button_im_pj.show() 573 574 self.scr_exe_button_setup_icon.show() 575 self.scr_exe_button_im_setup_icon.show() 576 self.scr_exe_hbox_setup_icon.show() 577 578 self.scr_exe_label_menu_name.show() 579 self.scr_exe_label_setup_name.show() 580 self.scr_exe_label_setup_icon.show() 581 self.scr_exe_label_setup_passwd.show() 582 583 self.scr_exe_entry_pj.show() 584 self.scr_exe_entry_setup_name.show() 585 self.scr_exe_entry_setup_icon.show() 586 self.scr_exe_entry_setup_passwd.show() 587 588 self.scr_exe_button_creation.show() 589 self.scr_exe_button_im_creation.show() 590 self.scr_exe_label_button_creation.show() 591 self.scr_exe_button_creation_hbox.show() 592 self.scr_exe_button_creation_hbox2.show() 593 594 self.scr_exe_frame_pj.show() 595 self.scr_exe_frame_executable.show() 596 self.scr_exe_frame_setup.show() 597 598 self.scr_exe_cbox_executable.show() 599 self.scr_exe_pj_hbox.show() 600 601 self.scr_exe_setup_vbox_left.show() 602 self.scr_exe_setup_vbox_right.show() 603 self.scr_exe_setup_hbox.show() 604 605 self.scr_exe_vbox.hide()
606 607 608 609 610 #===================================================# 611 # Ecran de parametrage de l'appli # 612 #===================================================#
613 - def scr_param(self):
614 """ 615 The parameters screen 616 617 PARAMETERS 618 ========== 619 None 620 621 RETURNS 622 ======= 623 None 624 """ 625 self.scr_param_table = gtk.Table(rows=3, columns=2, homogeneous=True) 626 627 self.scr_param_frame = gtk.Frame(label = self.scr_param_text_lang) 628 self.scr_param_cbox = gtk.combo_box_new_text() 629 self.scr_param_cbox.connect("changed", self.p_lang_change) 630 631 self.scr_param_button_open = gtk.Button(self.scr_param_text_open) 632 self.scr_param_button_open.connect("clicked", self.p_config_open) 633 self.scr_param_button_save = gtk.Button(self.scr_param_text_save) 634 self.scr_param_button_save.connect("clicked", self.p_config_save) 635 self.scr_param_button_about = gtk.Button(self.scr_param_text_about) 636 self.scr_param_button_about.connect("clicked", self.win_about) 637 self.scr_param_button_doc = gtk.Button(self.scr_param_text_doc) 638 self.scr_param_button_doc.connect("clicked", self.p_notice) 639 640 self.scr_param_frame.add(self.scr_param_cbox) 641 642 self.scr_param_table.attach(self.scr_param_button_open,0,1,0,1,gtk.EXPAND|gtk.FILL,gtk.SHRINK,xpadding=4,ypadding=4) 643 self.scr_param_table.attach(self.scr_param_button_save,0,1,1,2,gtk.EXPAND|gtk.FILL,gtk.SHRINK,xpadding=4,ypadding=4) 644 self.scr_param_table.attach(self.scr_param_button_doc,0,1,2,3,gtk.EXPAND|gtk.FILL,gtk.SHRINK,xpadding=4,ypadding=4) 645 self.scr_param_table.attach(self.scr_param_frame,1,2,0,1,gtk.EXPAND|gtk.FILL,gtk.SHRINK,xpadding=4,ypadding=4) 646 self.scr_param_table.attach(self.scr_param_button_about,1,2,1,2,gtk.EXPAND|gtk.FILL,gtk.SHRINK,xpadding=4,ypadding=4) 647 648 self.scr_param_button_open.show() 649 self.scr_param_button_save.show() 650 self.scr_param_button_about.show() 651 self.scr_param_button_doc.show() 652 self.scr_param_frame.show() 653 self.scr_param_cbox.show() 654 655 x, y = self.scr_exe_vbox.size_request() 656 self.scr_param_table.set_size_request(x, y) 657 658 self.scr_param_table.hide()
659 660 661 662 663 #===================================================# 664 # Procedure lancant l'affichage de la doc PDF # 665 #===================================================#
666 - def p_notice(self, widget):
667 """ 668 Launch the PDF documentation 669 670 PARAMETERS 671 ========== 672 widget 673 ------ 674 The widget that call the procedure 675 676 RETURNS 677 ======= 678 None 679 """ 680 #Ne fonctionne que sous windows 681 os.startfile(os.path.join(self.path_base,"/00-DOC/Pyxmaker_Notice.pdf"))
682 683 684 685 686 #===================================================# 687 # Procedure gerant le bouton "ecran precedent" # 688 #===================================================#
689 - def scr_change_previous(self, widget):
690 """ 691 Manage the "previous screen" button, and screens display 692 693 PARAMETERS 694 ========== 695 widget 696 ------ 697 The widget that call the procedure 698 699 RETURNS 700 ======= 701 None 702 """ 703 if self.scr_idx == 1: 704 self.scr_idx = 0 705 self.scr_info_vbox.show() 706 self.scr_title(self.scr_info_text_title) 707 708 self.scr_exe_vbox.hide() 709 self.scr_param_table.hide() 710 711 self.scr_base_win_button_previous.set_sensitive(False) 712 self.scr_base_win_button_next.set_sensitive(True) 713 714 elif self.scr_idx == 2: 715 self.scr_idx = 1 716 self.scr_exe_vbox.show() 717 self.scr_title(self.scr_exe_text_title) 718 719 self.scr_info_vbox.hide() 720 self.scr_param_table.hide() 721 722 self.scr_base_win_button_previous.set_sensitive(True) 723 self.scr_base_win_button_next.set_sensitive(True)
724 725 726 727 728 #===================================================# 729 # Procedure gerant le bouton "ecran suivant" # 730 #===================================================#
731 - def scr_change_next(self, widget):
732 """ 733 Manage the "next screen" button, and screens display 734 735 PARAMETERS 736 ========== 737 widget 738 ------ 739 The widget that call the procedure 740 741 RETURNS 742 ======= 743 None 744 """ 745 if self.scr_idx == 0: 746 self.scr_idx = 1 747 self.scr_exe_vbox.show() 748 self.scr_title(self.scr_exe_text_title) 749 750 self.scr_exe_entry_setup_name.set_text(self.scr_info_entry_name.get_text() + "_" + self.scr_info_entry_version.get_text()) 751 752 self.scr_info_vbox.hide() 753 self.scr_param_table.hide() 754 755 self.scr_base_win_button_next.set_sensitive(True) 756 self.scr_base_win_button_previous.set_sensitive(True) 757 758 elif self.scr_idx == 1: 759 self.scr_idx = 2 760 self.scr_param_table.show() 761 self.scr_title(self.scr_param_text_title) 762 763 self.scr_info_vbox.hide() 764 self.scr_exe_vbox.hide() 765 766 self.scr_base_win_button_next.set_sensitive(False) 767 self.scr_base_win_button_previous.set_sensitive(True)
768 769 770 771 772 #===================================================# 773 # Fenetre a propos de # 774 #===================================================#
775 - def win_about(self, widget):
776 """ 777 Show About window dialog 778 779 PARAMETERS 780 ========== 781 widget 782 ------ 783 The widget that call the procedure 784 785 RETURNS 786 ======= 787 None 788 """ 789 about_win = gtk.AboutDialog() 790 about_win.set_name(self.dict_about["SOFT_NAME"]) 791 about_win.set_version(self.dict_about["VERSION"]) 792 about_win.set_copyright(self.dict_about["COPYRIGHT"]) 793 about_win.set_comments(self.dict_about["COMMENTS"]) 794 about_win.set_license(self.dict_about["LICENCE"]) 795 about_win.set_website(self.dict_about["WEBSITE"]) 796 about_win.set_website_label(self.dict_about["WEBSITE_LABEL"]) 797 about_win.set_authors([self.dict_about["AUTHORS"]]) 798 about_win.set_documenters([self.dict_about["DOCUMENTERS"]]) 799 about_win.set_translator_credits(self.dict_about["CREDITS"]) 800 about_win.run() 801 about_win.destroy()
802 803 804 805 806 #===================================================# 807 # Fenetre Question # 808 #===================================================#
809 - def win_question(self, widget, texte=""):
810 """ 811 Show a question window to the user with YES/NO buttons 812 813 PARAMETERS 814 ========== 815 widget 816 ------ 817 The widget that call the procedure 818 819 texte 820 ----- 821 The text to display in the question window 822 823 RETURNS 824 ======= 825 The answer (True or False) of the user 826 """ 827 quote_win = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, texte) 828 reponse = quote_win.run() 829 quote_win.destroy() 830 831 if reponse == gtk.RESPONSE_YES: 832 rtr_quote = True 833 else: 834 rtr_quote = False 835 836 837 return rtr_quote
838 839 840 841 842 #===================================================# 843 # Fenetre Info # 844 #===================================================#
845 - def win_info(self, widget, texte=""):
846 """ 847 Create an info window. Wait ack to continue 848 849 PARAMETERS 850 ========== 851 widget 852 ------ 853 The widget that call the procedure 854 855 texte 856 ----- 857 The text to display in the question window 858 859 RETURNS 860 ======= 861 None 862 """ 863 info_win = gtk.MessageDialog(self.scr_base_win, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, texte) 864 response = info_win.run() 865 info_win.show() 866 info_win.destroy()
867 868 869 870 871 #===================================================# 872 # Fenetre Erreur # 873 #===================================================#
874 - def win_error(self, widget, texte=""):
875 """ 876 Create an error window with texte. Wait ack to continue 877 878 PARAMETERS 879 ========== 880 widget 881 ------ 882 The widget that call the procedure 883 884 texte 885 ----- 886 The text to display in the question window 887 888 RETURNS 889 ======= 890 None 891 """ 892 error_win = gtk.MessageDialog(self.scr_base_win, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, texte) 893 response = error_win.run() 894 error_win.destroy()
895 896 897 898 899 #===================================================# 900 # Fenetre de confirmation de creation # 901 #===================================================#
902 - def win_confirm(self):
903 """ 904 Display the different listing to the user for validation 905 before generate the executable 906 907 PARAMETERS 908 ========== 909 None 910 911 RETURNS 912 ======= 913 None 914 """ 915 self.win_confirm_win = gtk.Window(type=gtk.WINDOW_TOPLEVEL) 916 self.win_confirm_vbox = gtk.VBox() 917 918 self.win_confirm_frame_include = gtk.Frame(label = "Include") 919 self.win_confirm_frame_exclude = gtk.Frame(label = "Exclude") 920 self.win_confirm_frame_package = gtk.Frame(label = "Package") 921 self.win_confirm_frame_include_file = gtk.Frame(label = "Include File") 922 923 self.win_confirm_entry_include = gtk.Entry() 924 self.win_confirm_entry_exclude = gtk.Entry() 925 self.win_confirm_entry_package = gtk.Entry() 926 self.win_confirm_entry_include_file = gtk.Entry() 927 928 self.win_confirm_button = gtk.Button("OK") 929 self.win_confirm_button.connect("clicked", self.p_win_confirm_response) 930 931 self.win_confirm_entry_include.set_text(self.dico_param["CXF_INCLUDE"]) 932 self.win_confirm_entry_exclude.set_text(self.dico_param["CXF_EXCLUDE"]) 933 self.win_confirm_entry_package.set_text(self.dico_param["CXF_PACKAGE"]) 934 self.win_confirm_entry_include_file.set_text(self.dico_param["CXF_INCLUDE_FILE"]) 935 936 self.win_confirm_frame_include.add(self.win_confirm_entry_include) 937 self.win_confirm_frame_exclude.add(self.win_confirm_entry_exclude) 938 self.win_confirm_frame_package.add(self.win_confirm_entry_package) 939 self.win_confirm_frame_include_file.add(self.win_confirm_entry_include_file) 940 941 self.win_confirm_vbox.pack_start(self.win_confirm_frame_include) 942 self.win_confirm_vbox.pack_start(self.win_confirm_frame_exclude) 943 self.win_confirm_vbox.pack_start(self.win_confirm_frame_package) 944 self.win_confirm_vbox.pack_start(self.win_confirm_frame_include_file) 945 self.win_confirm_vbox.pack_start(self.win_confirm_button, expand = False, fill = False, padding = 4) 946 947 self.win_confirm_entry_include.show() 948 self.win_confirm_entry_exclude.show() 949 self.win_confirm_entry_package.show() 950 self.win_confirm_entry_include_file.show() 951 self.win_confirm_frame_include.show() 952 self.win_confirm_frame_exclude.show() 953 self.win_confirm_frame_package.show() 954 self.win_confirm_frame_include_file.show() 955 self.win_confirm_button.show() 956 self.win_confirm_vbox.show() 957 958 self.win_confirm_win.add(self.win_confirm_vbox) 959 self.win_confirm_win.set_transient_for(self.scr_base_win) 960 self.win_confirm_win.set_modal(True) 961 self.win_confirm_win.set_transient_for(self.scr_base_win) 962 963 x, y = self.win_confirm_win.size_request() 964 self.win_confirm_win.resize(self.x,y) 965 966 self.win_confirm_win.show_now()
967 968 969 970 971 #===================================================# 972 # Procédure validant la generation # 973 #===================================================#
974 - def p_win_confirm_response(self, widget):
975 """ 976 Allow to valid the scripts creation 977 978 PARAMETERS 979 ========== 980 widget 981 ------ 982 The widget that call the procedure 983 984 RETURNS 985 ======= 986 None 987 """ 988 self.dico_param["CXF_INCLUDE"] = self.win_confirm_entry_include.get_text() 989 self.dico_param["CXF_EXCLUDE"] = self.win_confirm_entry_exclude.get_text() 990 self.dico_param["CXF_PACKAGE"] = self.win_confirm_entry_package.get_text() 991 self.dico_param["CXF_INCLUDE_FILE"] = self.win_confirm_entry_include_file.get_text() 992 993 self.win_confirm_win.destroy() 994 995 rtr = self.fct_gener_setup(self.dico_param) 996 997 if rtr == 0: 998 self.win_info(None, self.scr_all_text_gener_ok) 999 elif rtr == 1: 1000 self.win_info(None, self.scr_all_text_gener_ko) 1001 else: 1002 self.win_info(None, self.scr_all_text_gener_oko)
1003 1004 1005 1006 1007 #===================================================# 1008 # Procedure qui alimente la combobox de langues # 1009 #===================================================#
1010 - def p_lang_alim(self):
1011 """ 1012 Allow to supply the language combobox 1013 1014 PARAMETERS 1015 ========== 1016 None 1017 1018 RETURNS 1019 ======= 1020 None 1021 """ 1022 for i in range(len(self.listing_lang)): 1023 self.scr_param_cbox.append_text(self.listing_lang[i][0]) 1024 1025 if (self.listing_lang[i][0] == self.dict_config["LANG"]): 1026 self.scr_param_iter_cbox_lang = i 1027 1028 self.scr_param_cbox.set_active(self.scr_param_iter_cbox_lang)
1029 1030 1031 1032 1033 #===================================================# 1034 # Procedure pour changer la langue de l'IHM # 1035 #===================================================#
1036 - def p_lang_change(self, widget):
1037 """ 1038 Allow to change the language 1039 1040 PARAMETERS 1041 ========== 1042 widget 1043 ------ 1044 The widget that call the procedure 1045 1046 RETURNS 1047 ======= 1048 None 1049 """ 1050 self.fct_lang_change(self.scr_param_cbox.get_active_text())
1051 1052 1053 1054 1055 #===================================================# 1056 # Procedure pour charger la configuration du PJ # 1057 #===================================================#
1058 - def p_config_open(self, widget):
1059 """ 1060 Allow to load the project configuration 1061 1062 PARAMETERS 1063 ========== 1064 widget 1065 ------ 1066 The widget that call the procedure 1067 1068 RETURNS 1069 ======= 1070 None 1071 """ 1072 config_open_win = gtk.FileChooserDialog(title=self.scr_exe_text_setup_icon, \ 1073 parent=None, action=gtk.FILE_CHOOSER_ACTION_OPEN, \ 1074 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) #buttons: type puis signal renvoyé, par paire 1075 1076 filtre_config_open = gtk.FileFilter() 1077 filtre_config_open.set_name("pyxmaker") 1078 filtre_config_open.add_pattern("*.pxmk") 1079 1080 config_open_win.set_select_multiple(False) 1081 config_open_win.set_do_overwrite_confirmation(True) 1082 config_open_win.add_filter(filtre_config_open) 1083 1084 config_open_win.set_filename("save.pxmk") 1085 1086 retour = config_open_win.run() 1087 file_chose = config_open_win.get_filename() 1088 1089 if (retour == gtk.RESPONSE_OK): 1090 dict_param = self.fct_config_open(file_chose) 1091 self.scr_info_entry_name.set_text(dict_param["NAME"]) 1092 self.scr_info_entry_version.set_text(dict_param["VERSION"]) 1093 self.scr_info_entry_author.set_text(dict_param["AUTHOR"]) 1094 self.scr_info_entry_author_mail.set_text(dict_param["AUTHOR_MAIL"]) 1095 self.scr_info_entry_maintenor.set_text(dict_param["MAINTAINER"]) 1096 self.scr_info_entry_maintenor_mail.set_text(dict_param["MAINTAINER_MAIL"]) 1097 self.scr_info_entry_fast_description.set_text(dict_param["DESCRIPTION"]) 1098 self.scr_info_entry_website.set_text(dict_param["WEBSITE"]) 1099 self.scr_exe_entry_pj.set_text(dict_param["DIR_PJ"]) 1100 self.scr_exe_entry_setup_name.set_text(dict_param["SETUP_NAME"]) 1101 self.scr_exe_entry_setup_icon.set_text(dict_param["SETUP_ICON"]) 1102 self.scr_exe_entry_setup_passwd.set_text(dict_param["SETUP_PASSWD"]) 1103 1104 if dict_param["WINCONS"] == "True": 1105 self.mode_wincons.set_active(True) 1106 else: 1107 self.mode_wincons.set_active(False) 1108 1109 nb = 0 1110 1111 try: 1112 nb = self.f_load_cbox_exec(None) 1113 except: 1114 self.win_error(None, self.scr_all_text_path_error) 1115 1116 self.scr_exe_cbox_executable.set_active(0) 1117 i = 0 1118 while self.scr_exe_cbox_executable.get_active_text() <> dict_param["EXECUTABLE"] and i < nb: 1119 i += 1 1120 self.scr_exe_cbox_executable.set_active(i) 1121 1122 self.scr_exe_entry_setup_name.set_text(self.scr_info_entry_name.get_text() + "_" + self.scr_info_entry_version.get_text()) 1123 1124 config_open_win.destroy()
1125 1126 1127 1128 1129 #===================================================# 1130 # Procedure pour sauvegarder la configuration PJ # 1131 #===================================================#
1132 - def p_config_save(self, widget):
1133 """ 1134 Allow to save the project configuration 1135 1136 PARAMETERS 1137 ========== 1138 widget 1139 ------ 1140 The widget that call the procedure 1141 1142 RETURNS 1143 ======= 1144 None 1145 """ 1146 dict_param, test = self.f_generate_dict_param() 1147 1148 if test: 1149 p_config_save = gtk.FileChooserDialog(title=self.scr_exe_text_setup_icon, \ 1150 parent=None, action=gtk.FILE_CHOOSER_ACTION_SAVE, \ 1151 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) #buttons: type puis signal renvoyé, par paire 1152 1153 filtre_p_config_save = gtk.FileFilter() 1154 filtre_p_config_save.set_name("pyxmaker") 1155 filtre_p_config_save.add_pattern("*.pxmk") 1156 1157 p_config_save.set_select_multiple(False) 1158 p_config_save.set_do_overwrite_confirmation(True) 1159 p_config_save.add_filter(filtre_p_config_save) 1160 1161 p_config_save.set_filename("save.pxmk") 1162 1163 retour = p_config_save.run() 1164 file_chose = p_config_save.get_filename() 1165 1166 if (retour == gtk.RESPONSE_OK): 1167 if file_chose.find(".pxmk") == -1: 1168 file_chose += ".pxmk" 1169 self.fct_p_config_save(file_chose, dict_param) 1170 1171 p_config_save.destroy()
1172 1173 1174 1175 1176 #===================================================# 1177 # Procedure pour choisir le dossier du PJ # 1178 #===================================================#
1179 - def p_select_dir_pj(self, widget):
1180 """ 1181 Allow to choose the project directory 1182 1183 PARAMETERS 1184 ========== 1185 widget 1186 ------ 1187 The widget that call the procedure 1188 1189 RETURNS 1190 ======= 1191 None 1192 """ 1193 dir_pj = gtk.FileChooserDialog(title=self.scr_exe_text_pj_dir, \ 1194 parent=None, action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, \ 1195 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) #buttons: type puis signal renvoyé, par paire 1196 1197 dir_pj.set_select_multiple(False) 1198 dir_pj.set_do_overwrite_confirmation(True) 1199 retour = dir_pj.run() 1200 if retour == gtk.RESPONSE_OK: 1201 self.scr_exe_entry_pj.set_text(dir_pj.get_filename()) 1202 self.f_load_cbox_exec(None) 1203 dir_pj.destroy()
1204 1205 1206 1207 1208 #===================================================# 1209 # Procedure pour choisir l'icone de l'install # 1210 #===================================================#
1211 - def p_select_setup_icon(self, widget):
1212 """ 1213 Allow to choose an icon for the setup install 1214 1215 PARAMETERS 1216 ========== 1217 widget 1218 ------ 1219 The widget that call the procedure 1220 1221 RETURNS 1222 ======= 1223 None 1224 """ 1225 setup_icon = gtk.FileChooserDialog(title=self.scr_exe_text_setup_icon, \ 1226 parent=None, action=gtk.FILE_CHOOSER_ACTION_OPEN, \ 1227 buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) #buttons: type puis signal renvoyé, par paire 1228 1229 filtre_setup_icon = gtk.FileFilter() 1230 filtre_setup_icon.set_name("ico") 1231 filtre_setup_icon.add_pattern("*.ico") 1232 1233 setup_icon.set_select_multiple(False) 1234 setup_icon.set_do_overwrite_confirmation(True) 1235 setup_icon.add_filter(filtre_setup_icon) 1236 retour = setup_icon.run() 1237 file_chose = setup_icon.get_filename() 1238 if (retour == gtk.RESPONSE_OK) and (file_chose.find(".ico") <> -1): 1239 self.scr_exe_entry_setup_icon.set_text(setup_icon.get_filename()) 1240 setup_icon.destroy()
1241 1242 1243 1244 1245 #===================================================# 1246 #Fonction qui liste les fichiers .py et les packages# 1247 #===================================================#
1248 - def f_load_py(self, path):
1249 """ 1250 Allow to create listing for .py file and package 1251 1252 PARAMETERS 1253 ========== 1254 path 1255 ---- 1256 the path to analyze 1257 RETURNS 1258 ======= 1259 Two listing that contains the .py files and the directories 1260 """ 1261 listing_file = [] 1262 listing_dir = [] 1263 self.listing_ico = [] 1264 for file_rd in os.listdir(path): 1265 if (not os.path.isdir(os.path.join(path, file_rd))) and (file_rd.find(".py") <> -1) and \ 1266 (file_rd.find(".pyc") == -1) and (file_rd.find(".py~") == -1): 1267 listing_file.append(file_rd) 1268 if (not os.path.isdir(os.path.join(path, file_rd))) and (file_rd.find(".ico") <> -1): 1269 self.listing_ico.append(file_rd) 1270 1271 1272 elif os.path.isdir(os.path.join(path, file_rd)): 1273 listing_dir.append(file_rd) 1274 1275 self.p_cxf_listing(listing_file, listing_dir, path) 1276 1277 return listing_file, listing_dir
1278 1279 1280 1281 1282 #===================================================# 1283 # Fonction qui charge la combobox # 1284 #===================================================#
1285 - def f_load_cbox_exec(self, widget):
1286 """ 1287 Allow to supply the .py combobox on executable screen 1288 1289 PARAMETERS 1290 ========== 1291 widget 1292 ------ 1293 The widget that call the procedure 1294 1295 RETURNS 1296 ======= 1297 The number of entries in the combobox 1298 """ 1299 path = self.scr_exe_entry_pj.get_text() 1300 listing_py, listing_dir = self.f_load_py(path) 1301 1302 self.scr_exe_cbox_executable.get_model().clear() 1303 1304 for i in listing_py: 1305 self.scr_exe_cbox_executable.append_text(i) 1306 1307 return len(listing_py)
1308 1309 1310 1311 1312 #===================================================# 1313 # Fonction qui analyse les fichiers # 1314 #===================================================#
1315 - def f_file_analyze(self, path, listing_file):
1316 """ 1317 Allow to analyze .py file 1318 1319 PARAMETERS 1320 ========== 1321 path 1322 ---- 1323 The package path to analyze 1324 listing_file 1325 ------------ 1326 Contains the file to analyse 1327 1328 RETURNS 1329 ======= 1330 None 1331 """ 1332 for f in listing_file: 1333 with open(r"%s"%(os.path.join(path,f),), "r") as file_rd: 1334 file_line = file_rd.readline() 1335 while file_line <> "": 1336 if file_line.split(" ")[0] in ("import","from"): 1337 if self.listing_include.count(file_line.split()[1]) == 0: 1338 self.listing_include.append(file_line.split()[1]) 1339 1340 file_line = file_rd.readline()
1341 1342 1343 1344 1345 #===================================================# 1346 # Fonction qui analyse les packages # 1347 #===================================================#
1348 - def f_package_analyze(self, path):
1349 """ 1350 Allow to recursively analyze packages 1351 1352 PARAMETERS 1353 ========== 1354 path 1355 ---- 1356 The package path to analyze 1357 1358 RETURNS 1359 ======= 1360 A list of import to add 1361 """ 1362 listing_imp = [] 1363 1364 for rd in os.listdir(path + "/"): 1365 if (not os.path.isdir(os.path.join(path,rd)) and rd[len(rd)-3:] == ".py" and \ 1366 rd <> "__init__.py"): 1367 self.f_file_analyze(path, [rd]) 1368 1369 elif os.path.isdir(os.path.join(path,rd)): 1370 if "__init__.py" in os.listdir(os.path.join(path, rd )): 1371 rtr = self.f_package_analyze(os.path.join(path, rd)) 1372 1373 if len(rtr) >0: 1374 listing_imp.extend(rtr) 1375 1376 return listing_imp
1377 1378 1379 1380 1381 #===================================================# 1382 # Procedure creant les listing pour cx_freeze # 1383 #===================================================#
1384 - def p_cxf_listing(self, listing_file, listing_dir, path):
1385 """ 1386 Create the different listing for the cx_freeze script 1387 1388 PARAMETERS 1389 ========== 1390 listing_file 1391 ------------ 1392 The different .py files 1393 listing_dir 1394 ----------- 1395 The different directories, and potential package 1396 path 1397 ---- 1398 The path whele files are located 1399 RETURNS 1400 ======= 1401 None 1402 """ 1403 self.listing_include = [] 1404 self.listing_exclude = [] 1405 self.listing_package = [] 1406 self.listing_include_file = [] 1407 1408 1409 self.f_file_analyze(path, listing_file) 1410 1411 1412 for d in listing_dir: 1413 if d[0] in ("0","1","2","3","4","5","6","7","8","9"): 1414 self.listing_include_file.append(d) 1415 1416 elif d[0] == "_": 1417 pass 1418 1419 else: 1420 for file_rd in os.listdir(os.path.join(path,d)): 1421 if (not os.path.isdir(os.path.join(os.path.join(path,d),file_rd)) and \ 1422 (file_rd == "__init__.py")): 1423 self.listing_package.append(d) 1424 1425 for i in range(len(self.listing_include)): 1426 if self.listing_include[i] == d: 1427 self.listing_include.remove(d) 1428 1429 for package in self.listing_package: 1430 listt = self.f_package_analyze(os.path.join(path, package)) 1431 self.listing_include.extend(listt)
1432 1433 1434 1435 1436 #===================================================# 1437 # Fonction generant le dictionnaire de parametres # 1438 #===================================================#
1439 - def f_generate_dict_param(self):
1440 """ 1441 Allow to generate the parameters dctionnary 1442 1443 PARAMETERS 1444 ========== 1445 None 1446 1447 RETURNS 1448 ======= 1449 A dictionnary that contains parameters 1450 A boolean that indicate the dictionnary creation status 1451 """ 1452 modele_version = "^([-\.]?[0-9]{1,}){1,}$" 1453 modele_mail = "^.{1,}(@).{1,}(\.).{1,}$" 1454 modele_web = "^(http)s{,1}(://).{1,}(\.).{1,}$" 1455 1456 if (self.scr_info_entry_name.get_text() <> "" and self.scr_info_entry_version.get_text() <> "" and \ 1457 self.scr_info_entry_author.get_text() <> "" and self.scr_info_entry_author_mail.get_text() <> "" and \ 1458 self.scr_info_entry_maintenor.get_text() <> "" and self.scr_info_entry_maintenor_mail.get_text() <> "" and \ 1459 self.scr_info_entry_fast_description.get_text() <> "" and self.scr_info_entry_website.get_text() <> "" and \ 1460 self.scr_exe_entry_pj.get_text() <> "" and self.scr_exe_entry_setup_name.get_text() <> "") and \ 1461 (re.search(modele_mail,self.scr_info_entry_author_mail.get_text()) <> None and \ 1462 re.search(modele_mail,self.scr_info_entry_maintenor_mail.get_text()) <> None and \ 1463 re.search(modele_web,self.scr_info_entry_website.get_text()) <> None and \ 1464 re.search(modele_version, self.scr_info_entry_version.get_text()) <> None): 1465 1466 STRUCT_PATH = self.scr_exe_entry_pj.get_text() + "\\..\\" + self.scr_info_entry_name.get_text().upper() + "_WIN\\" 1467 SETUP_PATH = STRUCT_PATH + "SETUP\\" 1468 SETUP_EXE_PATH = SETUP_PATH + "EXE\\" 1469 PJ_PATH = STRUCT_PATH + self.scr_info_entry_name.get_text().upper() + "\\" 1470 1471 SETUP_EXEC_WITHOUT_PY = self.scr_exe_cbox_executable.get_active_text().split(".")[0] + ".exe" 1472 1473 SCRIPTS_PATH = self.path_base + "\\01-REFS\\" 1474 1475 test_icon = os.path.join(self.scr_exe_entry_pj.get_text(),"icone.ico") 1476 print test_icon 1477 print os.path.exists(test_icon) 1478 if os.path.exists(test_icon) and self.listing_include_file.count("icone.ico") == 0: 1479 self.listing_include_file.append("icone.ico") 1480 1481 LIST_INC = "" 1482 if len(self.listing_include) > 0: 1483 LIST_INC = "\"" + self.listing_include[0] + "\"" 1484 if len(self.listing_include) > 1: 1485 LIST_INC += "," 1486 for i in range(1, len(self.listing_include)): 1487 LIST_INC += "\"" + self.listing_include[i] + "\"" 1488 if i < (len(self.listing_include)-1): 1489 LIST_INC += "," 1490 1491 1492 LIST_EXC = "" 1493 if len(self.listing_exclude) > 0: 1494 LIST_EXC = "\"" + self.listing_exclude[0] + "\"" 1495 if len(self.listing_exclude) > 1: 1496 LIST_EXC += "," 1497 for i in range(1, len(self.listing_exclude)): 1498 LIST_EXC += "\"" + self.listing_exclude[i] + "\"" 1499 if i < (len(self.listing_exclude)-1): 1500 LIST_EXC += "," 1501 1502 1503 LIST_PAC = "" 1504 if len(self.listing_package) > 0: 1505 LIST_PAC = "\"" + self.listing_package[0] + "\"" 1506 if len(self.listing_package) > 1: 1507 LIST_PAC += "," 1508 for i in range(1, len(self.listing_package)): 1509 LIST_PAC += "\"" + self.listing_package[i] + "\"" 1510 if i < (len(self.listing_package)-1): 1511 LIST_PAC += "," 1512 1513 1514 LIST_INC_F = "" 1515 if len(self.listing_include_file) > 0: 1516 LIST_INC_F = "\"" + self.listing_include_file[0] + "\"" 1517 if len(self.listing_include_file) > 1: 1518 LIST_INC_F += "," 1519 for i in range(1, len(self.listing_include_file)): 1520 LIST_INC_F += "\"" + self.listing_include_file[i] + "\"" 1521 if i < (len(self.listing_include_file)-1): 1522 LIST_INC_F += "," 1523 1524 1525 if len(self.listing_ico) > 0: 1526 ico = self.listing_ico[0] 1527 else: 1528 ico = "" 1529 1530 dict_param = {} 1531 dict_param["NAME"] = self.scr_info_entry_name.get_text() 1532 dict_param["VERSION"] = self.scr_info_entry_version.get_text() 1533 dict_param["AUTHOR"] = self.scr_info_entry_author.get_text() 1534 dict_param["AUTHOR_MAIL"] = self.scr_info_entry_author_mail.get_text() 1535 dict_param["MAINTAINER"] = self.scr_info_entry_maintenor.get_text() 1536 dict_param["MAINTAINER_MAIL"] = self.scr_info_entry_maintenor_mail.get_text() 1537 dict_param["DESCRIPTION"] = self.scr_info_entry_fast_description.get_text() 1538 dict_param["WEBSITE"] = self.scr_info_entry_website.get_text() 1539 dict_param["DIR_PJ"] = self.scr_exe_entry_pj.get_text() 1540 dict_param["ICON_EXEC"] = ico 1541 dict_param["ICON"] = dict_param["ICON_EXEC"] 1542 dict_param["SETUP_NAME"] = self.scr_exe_entry_setup_name.get_text() 1543 dict_param["EXECUTABLE"] = self.scr_exe_cbox_executable.get_active_text() 1544 dict_param["SETUP_ICON"] = self.scr_exe_entry_setup_icon.get_text() 1545 dict_param["SETUP_PASSWD"] = self.scr_exe_entry_setup_passwd.get_text() 1546 dict_param["SETUP_MENU"] = self.scr_info_entry_name.get_text() 1547 dict_param["SETUP_EXEC_WITHOUT_PY"] = SETUP_EXEC_WITHOUT_PY 1548 dict_param["SETUP_UID"] = str(uuid.uuid5(uuid.uuid1(uuid.getnode(), int(time.time())),dict_param["NAME"] + "_" + dict_param["VERSION"])) 1549 dict_param["SETUP_LICENCE"] = PJ_PATH + "_pxmk\Licence.txt" 1550 dict_param["SETUP_BEFORE"] = PJ_PATH + "_pxmk\Before.txt" 1551 dict_param["SETUP_AFTER"] = PJ_PATH + "_pxmk\After.txt" 1552 dict_param["CXF_INCLUDE"] = LIST_INC 1553 dict_param["CXF_EXCLUDE"] = LIST_EXC 1554 dict_param["CXF_PACKAGE"] = LIST_PAC 1555 dict_param["CXF_INCLUDE_FILE"] = LIST_INC_F 1556 dict_param["CXF_ICON_EXEC"] = PJ_PATH + "icon.ico" 1557 dict_param["SETUP_OUTPUT_DIR"] = SETUP_PATH 1558 dict_param["SETUP_PATH"] = SETUP_PATH 1559 dict_param["STRUCT_PATH"] = STRUCT_PATH 1560 dict_param["SETUP_EXE_PATH"] = SETUP_EXE_PATH 1561 dict_param["PJ_PATH"] = PJ_PATH 1562 dict_param["SCRIPTS_PATH"] = SCRIPTS_PATH 1563 dict_param["WINCONS"] = str(self.mode_wincons.get_active()) #True si cochée 1564 1565 for key, value in dict_param.items(): 1566 if dict_param[key] is None: 1567 dict_param[key] = "" 1568 1569 return dict_param, True 1570 else: 1571 self.win_error(None, self.scr_all_text_fields) 1572 return {}, False
1573 1574 1575 1576 1577 #===================================================# 1578 # Lance l'interface de generation # 1579 #===================================================#
1580 - def p_generate_global(self, widget):
1581 """ 1582 Launch the creation interface 1583 1584 PARAMETERS 1585 ========== 1586 widget 1587 ------ 1588 The widget that call the procedure 1589 1590 RETURNS 1591 ======= 1592 None 1593 """ 1594 self.dico_param, test = self.f_generate_dict_param() 1595 1596 if test: 1597 self.win_confirm()
1598 1599 1600 1601 1602 #=======================================================================# 1603 # Main de la classe # 1604 #=======================================================================# 1605 if __name__ == "__main__": 1606 None 1607