def __init__(self): """ Sets the Glade file where the about window is defined and Connects the signals and its handlers through GladeWindow __init__ """ ## Get the file with the about window filename = 'glade/update.ui' ## The widget list widget_list = ['ProgressBarUpdate', 'note_update', 'TextViewUpdate'] handlers = ['on_update_destroy_event', 'on_ok_update_clicked'] # The top three widget top_window = 'update' # Starts the Glade Window GladeWindow.__init__(self, filename, top_window, widget_list, handlers) # Add a timer callback to update the value of the progress bar self.timer = gobject.timeout_add(50, self.progress_timeout) # self.m_oPopen = popen2.Popen3('sh ../updhrp.sh') if os.name == "nt": self.i, self.o = os.popen4('..\updhrp.bat') else: self.i, self.o = os.popen4('sh ../updhrp.sh') self.widgets['note_update'].set_current_page(0) self.widgets['ProgressBarUpdate'].pulse() self.widgets['ProgressBarUpdate'].pulse() self.widgets['ProgressBarUpdate'].pulse()
def __init__( self ): """ Sets the Glade file where the about window is defined and Connects the signals and its handlers through GladeWindow __init__ """ ## Get the file with the about window filename = 'glade/update.ui' ## The widget list widget_list = [ 'ProgressBarUpdate', 'note_update', 'TextViewUpdate' ] handlers = ['on_update_destroy_event', 'on_ok_update_clicked'] # The top three widget top_window = 'update' # Starts the Glade Window GladeWindow.__init__(self, filename, top_window, widget_list, handlers) # Add a timer callback to update the value of the progress bar self.timer = gobject.timeout_add (50, self.progress_timeout) # self.m_oPopen = popen2.Popen3('sh ../updhrp.sh') if os.name=="nt": self.i,self.o = os.popen4('..\updhrp.bat') else: self.i,self.o = os.popen4('sh ../updhrp.sh') self.widgets['note_update'].set_current_page(0) self.widgets['ProgressBarUpdate'].pulse() self.widgets['ProgressBarUpdate'].pulse() self.widgets['ProgressBarUpdate'].pulse()
def __init__(self, a_ImagePath, a_ErrorLog): """ Creates a window and shows the processed image. """ self.m_oImagePath = a_ImagePath self.m_sErrorLog = a_ErrorLog self.m_sDefaultExt = ".png" self.m_fSizeIncrement = 0.2 self.m_iMinSize = 5 self.m_sDataDir = os.environ['HARPIA_DATA_DIR'] filename = self.m_sDataDir + 'glade/showwindow.ui' widget_list = ['processed_image', 'ShowWindow'] handlers = [ 'on_btnShowSave_clicked', 'on_btnShowClose_clicked', 'on_btnShowZoomIn_clicked', 'on_btnShowZoomOut_clicked', 'on_btnShowZoomDefault_clicked' ] top_window = 'ShowWindow' # Initializes the Gladewindow if (self.m_oImagePath == None) or (not os.path.exists(self.m_oImagePath)): print "No Image" self.Window = gtk.Window() self.Window.set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") self.Window.set_position(gtk.WIN_POS_CENTER) self.Window.resize(320, 240) self.Window.set_title(_("Processed Image")) self.Label = gtk.Label() ## Error Loading if self.m_sErrorLog == '' or self.m_sErrorLog == None: self.m_sErrorLog = _( "Chain not yet processed, Live Session or unknown error. \n Please try to process active chain again." ) t_sErrorText = _( "No image found. \n\tLog Error: \n\n") + self.m_sErrorLog self.Label.set_text(t_sErrorText) self.Label.show() self.Window.add(self.Label) self.Window.show() else: GladeWindow.__init__(self, filename, top_window, widget_list, handlers) #self.glade = gtk.glade.XML("../etc/GladeFiles/showwindow.glade") self.Window = self.widgets['ShowWindow'] #self.Image = self.glade.get_widget("processed_image") self.Image = self.widgets['processed_image'] self.Window.set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") self.Window.set_position(gtk.WIN_POS_CENTER) self.Window.resize(640, 480) self.Label = gtk.Label() self.m_oImage = gtk.gdk.pixbuf_new_from_file(self.m_oImagePath) self.m_oOriginalImage = gtk.gdk.pixbuf_new_from_file( self.m_oImagePath) self.Image.set_from_pixbuf( gtk.gdk.pixbuf_new_from_file(self.m_oImagePath)) FileReader = file(self.m_oImagePath, "r") self.m_sFileRead = FileReader.read() FileReader.close() self.CurrentHeight = self.m_oOriginalImage.get_height() self.CurrentWidth = self.m_oOriginalImage.get_width()
def __init__(self): """ Constructor. Initializes the GladeWindow object for signal connecting, creates a dictionary for the Blocks and BlocksProperties and loads the configurations. """ self.exampleMenuItens = [] self.m_sDataDir = os.environ['HARPIA_DATA_DIR'] filename = self.m_sDataDir + 'glade/harpia_gui-1.0.ui' widget_list = [ 'HarpiaFrontend', 'SearchEntry', 'SearchButton', 'BlockDescription', 'WorkArea', 'BlocksTreeView', 'StatusLabel', 'ProcessImage', 'ProcessToolBar', 'CodeToolBar', 'UpdateToolBar', 'ViewSource', 'toolbar1', 'examples_menu', 'fake_separator' ] handlers = [ 'on_NewMenuBar_activate', 'on_OpenMenuBar_activate', 'on_SaveMenuBar_activate', 'on_SaveASMenuBar_activate', 'on_QuitMenuBar_activate', 'on_CutMenuBar_activate', 'on_CopyMenuBar_activate', 'on_PasteMenuBar_activate', 'on_DeleteMenuBar_activate', 'on_AboutMenuBar_activate', 'on_NewToolBar_clicked', 'on_OpenToolBar_clicked', 'on_SaveToolBar_clicked', 'on_ProcessToolBar_clicked', 'on_CodeToolBar_clicked', 'on_ZoomOutToolBar_clicked', 'on_ZoomInToolBar_clicked', 'on_SearchButton_clicked', 'on_BlocksTreeView_row_activated', 'on_BlocksTreeView_cursor_changed', 'on_HarpiaFrontend_destroy', 'on_ZoomDefaultToolBar_clicked', 'on_Preferences_clicked', 'on_Export_clicked', 'on_CloseMenuBar_activate', 'on_UpdateToolBar_clicked', 'on_tip_activate', 'on_ViewSource_clicked', 'on_reset_tip_activate' ] top_window = 'HarpiaFrontend' # Initializes the Gladewindow GladeWindow.__init__(self, filename, top_window, widget_list, handlers) self.top_window.maximize() # asking politely to maximize out app =] # Blocks self.Blocks = s2idirectory.groups for x in s2idirectory.block: self.Blocks[s2idirectory.block[x]["TreeGroup"]].append(s2idirectory.block[x]["Label"]) # Blocks Properties self.BlocksProperties = dict() for x in s2idirectory.block: self.BlocksProperties[s2idirectory.block[x]["Label"]] = {"Inputs": len(s2idirectory.block[x]["InTypes"]), "Outputs": len(s2idirectory.block[x]["OutTypes"])} self.widgets['HarpiaFrontend'].set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") self.m_oIconUpdate = gtk.Image() self.m_oIconUpdate.set_from_file(self.m_sDataDir + "images/system-software-update.png") self.m_oIconUpdate.show_all() self.widgets['UpdateToolBar'].set_icon_widget(self.m_oIconUpdate) self.g_sTreeViewPath = "0,0" if os.name == "nt": if not os.path.exists('../updhrp.bat'): self.widgets['toolbar1'].remove(self.widgets['UpdateToolBar']) else: if not os.path.exists('../updhrp.sh'): self.widgets['toolbar1'].remove(self.widgets['UpdateToolBar']) self.m_nStatus = 0 self.SaveAs = False # Member Diagram references self.m_oGcDiagrams = {} self.m_oSessionIDs = {} self.m_oCopyBuffer = (-1, -1) # tuple (fromPage, [listOfBlocks]) ...listOfConns? self.m_nCurrentIDSession = None self.LoadExamplesMenu() self.__InsertBlocks() self.on_CloseMenuBar_activate() # removing the dummie page self.on_NewToolBar_clicked() # creating blank page # Tip of The Day code tipOfTheDayWind = TipOfTheDay.TipOfTheDay() tipOfTheDayWind.run()
def __init__(self, Editor): """ The Constructor. Loads the glade object, and initializes the GladeWindow object for signal connecting. """ self.m_oEditor = Editor self.m_sDataDir = os.environ['HARPIA_DATA_DIR'] ## Imports the Glade file filename = self.m_sDataDir + 'glade/preferences.ui' # The widget list widget_list = [ 'preferences', 'PREFGridInt', 'PREFShowGrid', 'PREFServer', 'PREFPort' ] # Signal Handlers from the Buttons Confirm and Cancel handlers = [ 'on_preferences_confirm_clicked', 'on_preferences_cancel_clicked' ] # The Top window widget top_window = 'preferences' # Starts the GladeWindow, calling his __init__ method. GladeWindow.__init__(self, filename, top_window, widget_list, handlers) # Set the preferences Icon self.widgets['preferences'].set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") ## The Homefolder where the preferences will be stored. if os.name == "nt": self.HomeFolder = os.path.join(os.path.expanduser("~"), "harpiaFiles\\") else: self.HomeFolder = os.path.expanduser("~/harpiaFiles/") # self.HomeFolder = "/tmp/.harpia/" ## The Config File Path self.configfile = self.HomeFolder + "harpia.conf" # If the path do not exist, creates one. if not (os.path.exists(self.HomeFolder)): os.makedirs(self.HomeFolder, mode=0700) # If the path do not exist, creates one copyint the default harpia.conf. if not (os.path.exists(self.configfile)): shutil.copy("harpia.conf", self.HomeFolder) print "TESTE" + self.configfile ## A binderytool object, with the preferences stored self.m_oPreferencesXML = XMLParser(self.configfile) # --------------------------------- self.preferences = self.m_oPropertiesXML.getTag("harpia").getTag( "editor").getChildTags("property") # Load Preferences for Preference in self.preferences: if Preference.name == "show-grid": if Preference.value == "false": state = "False" else: state = "True" self.widgets['PREFShowGrid'].set_active(eval(state)) if Preference.name == "grid-int": self.widgets['PREFGridInt'].set_value(int(Preference.value)) if Preference.name == "server": self.widgets['PREFServer'].set_text(unicode(Preference.value)) if Preference.name == "port": self.widgets['PREFPort'].set_value(int(Preference.value))
def __init__(self, a_ImagePath, a_ErrorLog): """ Creates a window and shows the processed image. """ self.m_oImagePath = a_ImagePath self.m_sErrorLog = a_ErrorLog self.m_sDefaultExt = ".png" self.m_fSizeIncrement = 0.2 self.m_iMinSize = 5 self.m_sDataDir = os.environ["HARPIA_DATA_DIR"] filename = self.m_sDataDir + "glade/showwindow.glade" widget_list = ["processed_image", "ShowWindow"] handlers = [ "on_btnShowSave_clicked", "on_btnShowClose_clicked", "on_btnShowZoomIn_clicked", "on_btnShowZoomOut_clicked", "on_btnShowZoomDefault_clicked", ] top_window = "ShowWindow" # Initializes the Gladewindow if (self.m_oImagePath == None) or (not os.path.exists(self.m_oImagePath)): print "No Image" self.Window = gtk.Window() self.Window.set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") self.Window.set_position(gtk.WIN_POS_CENTER) self.Window.resize(320, 240) self.Window.set_title(_("Processed Image")) self.Label = gtk.Label() ## Error Loading if self.m_sErrorLog == "" or self.m_sErrorLog == None: self.m_sErrorLog = _( "Chain not yet processed, Live Session or unknown error. \n Please try to process active chain again." ) t_sErrorText = _("No image found. \n\tLog Error: \n\n") + self.m_sErrorLog self.Label.set_text(t_sErrorText) self.Label.show() self.Window.add(self.Label) self.Window.show() else: GladeWindow.__init__(self, filename, top_window, widget_list, handlers) # self.glade = gtk.glade.XML("../etc/GladeFiles/showwindow.glade") self.Window = self.widgets["ShowWindow"] # self.Image = self.glade.get_widget("processed_image") self.Image = self.widgets["processed_image"] self.Window.set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") self.Window.set_position(gtk.WIN_POS_CENTER) self.Window.resize(640, 480) self.Label = gtk.Label() self.m_oImage = gtk.gdk.pixbuf_new_from_file(self.m_oImagePath) self.m_oOriginalImage = gtk.gdk.pixbuf_new_from_file(self.m_oImagePath) self.Image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(self.m_oImagePath)) FileReader = file(self.m_oImagePath, "r") self.m_sFileRead = FileReader.read() FileReader.close() self.CurrentHeight = self.m_oOriginalImage.get_height() self.CurrentWidth = self.m_oOriginalImage.get_width()
def __init__(self): """ Constructor. Initializes the GladeWindow object for signal connecting, creates a dictionary for the Blocks and loads the configurations. """ self.exampleMenuItens = [] self.data_dir = os.environ['HARPIA_DATA_DIR'] filename = self.data_dir + 'glade/harpia_gui-1.0.ui' widget_list = [ 'HarpiaFrontend', 'SearchEntry', 'SearchButton', 'BlockDescription', 'WorkArea', 'BlocksTreeView', 'StatusLabel', 'ProcessImage', 'ProcessToolBar', 'CodeToolBar', 'ViewSource', 'toolbar1', 'examples_menu', 'fake_separator' ] handlers = [ 'on_NewMenuBar_activate', 'on_OpenMenuBar_activate', 'on_SaveMenuBar_activate', 'on_SaveASMenuBar_activate', 'on_QuitMenuBar_activate', 'on_CutMenuBar_activate', 'on_CopyMenuBar_activate', 'on_PasteMenuBar_activate', 'on_DeleteMenuBar_activate', 'on_AboutMenuBar_activate', 'on_NewToolBar_clicked', 'on_OpenToolBar_clicked', 'on_SaveToolBar_clicked', 'on_ProcessToolBar_clicked', 'on_CodeToolBar_clicked', 'on_ZoomOutToolBar_clicked', 'on_ZoomInToolBar_clicked', 'on_SearchButton_clicked', 'on_BlocksTreeView_row_activated', 'on_BlocksTreeView_cursor_changed', 'on_HarpiaFrontend_destroy', 'on_ZoomDefaultToolBar_clicked', 'on_Preferences_clicked', 'on_Export_clicked', 'on_CloseMenuBar_activate', 'on_tip_activate', 'on_ViewSource_clicked', 'on_reset_tip_activate' ] top_window = 'HarpiaFrontend' # Initializes the Gladewindow GladeWindow.__init__(self, filename, top_window, widget_list, handlers) self.top_window.maximize() # asking politely to maximize out app =] # Blocks self.Blocks = s2idirectory.groups for x in s2idirectory.block: self.Blocks[s2idirectory.block[x]["TreeGroup"]].append(s2idirectory.block[x]["Label"]) self.widgets['HarpiaFrontend'].set_icon_from_file(self.data_dir + "images/harpia_ave.png") self.tree_view_path = "0,0" self.status = 0 self.SaveAs = False # Member Diagram references self.diagrams = {} self.copy_buffer = (-1, -1) # tuple (fromPage, [listOfBlocks]) ...listOfConns? self.__load_examples_menu() self.__insert_blocks() self.on_CloseMenuBar_activate() # removing the dummie page self.on_NewToolBar_clicked() # creating blank page # Tip of The Day code tipOfTheDayWind = TipOfTheDay.TipOfTheDay() tipOfTheDayWind.run()
def __init__(self, Editor): """ The Constructor. Loads the glade object, and initializes the GladeWindow object for signal connecting. """ self.m_oEditor = Editor self.m_sDataDir = os.environ['HARPIA_DATA_DIR'] ## Imports the Glade file filename = self.m_sDataDir + 'glade/preferences.ui' # The widget list widget_list = ['preferences', 'PREFGridInt', 'PREFShowGrid', 'PREFServer', 'PREFPort'] # Signal Handlers from the Buttons Confirm and Cancel handlers = ['on_preferences_confirm_clicked', 'on_preferences_cancel_clicked'] # The Top window widget top_window = 'preferences' # Starts the GladeWindow, calling his __init__ method. GladeWindow.__init__(self, filename, top_window, widget_list, handlers) # Set the preferences Icon self.widgets['preferences'].set_icon_from_file(self.m_sDataDir + "images/harpia_ave.png") ## The Homefolder where the preferences will be stored. if os.name == "nt": self.HomeFolder = os.path.join(os.path.expanduser("~"), "harpiaFiles\\") else: self.HomeFolder = os.path.expanduser("~/harpiaFiles/") # self.HomeFolder = "/tmp/.harpia/" ## The Config File Path self.configfile = self.HomeFolder + "harpia.conf" # If the path do not exist, creates one. if not (os.path.exists(self.HomeFolder)): os.makedirs(self.HomeFolder, mode=0700) # If the path do not exist, creates one copyint the default harpia.conf. if not (os.path.exists(self.configfile)): shutil.copy("harpia.conf", self.HomeFolder) print "TESTE" + self.configfile ## A binderytool object, with the preferences stored self.m_oPreferencesXML = XMLParser(self.configfile) # --------------------------------- self.preferences = self.m_oPropertiesXML.getTag("harpia").getTag("editor").getChildTags("property") # Load Preferences for Preference in self.preferences: if Preference.name == "show-grid": if Preference.value == "false": state = "False" else: state = "True" self.widgets['PREFShowGrid'].set_active(eval(state)) if Preference.name == "grid-int": self.widgets['PREFGridInt'].set_value(int(Preference.value)) if Preference.name == "server": self.widgets['PREFServer'].set_text(unicode(Preference.value)) if Preference.name == "port": self.widgets['PREFPort'].set_value(int(Preference.value))