class BrowserBrick(BaseComponents.BlissWidget): def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) #map displayed string in the history list -> actual file path self.history_map = dict() self.layout = QVBoxLayout(self) self.defineSlot('load_file', ()) self.defineSlot('login_changed', ()) self.addProperty('mnemonic', 'string', '') self.addProperty('history', 'string', '', hidden=True) self.addProperty('sessions ttl (in days)', 'integer', '30') #make sure the history property is a pickled dict try: hist = pickle.loads(self.getProperty('history').getValue()) except: # EOFError if the string is empty but let's not count on it self.getProperty('history').setValue(pickle.dumps(dict())) # maybe defer that for later self.cleanup_history() self.main_layout = QSplitter(self) self.main_layout.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) # left part of the splitter self.history_box = QVBox(self.main_layout) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.sort_order = True self.sort_col = None self.history = QTable(self.history_box) self.history.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)) self.history.setSelectionMode(QTable.SingleRow) self.history.setNumCols(3) self.history.verticalHeader().hide() self.history.setLeftMargin(0) self.history.setSorting(False) QObject.connect(self.history, SIGNAL('currentChanged(int,int)'), self.history_changed) #by default sorting only sorts the columns and not whole rows. #let's reimplement that QObject.connect(self.history.horizontalHeader(), SIGNAL('clicked(int)'), self.sort_column) header = self.history.horizontalHeader() header.setLabel(0, 'Time and date') header.setLabel(1, 'Prefix') header.setLabel(2, 'Run number') self.clear_history_button = QPushButton('Clear history', self.history_box) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) QObject.connect(self.clear_history_button, SIGNAL('clicked()'), self.clear_history) # Right part of the splitter self.browser_box = QWidget(self.main_layout) QVBoxLayout(self.browser_box) self.browser_box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.top_layout = QHBoxLayout(self.browser_box) self.back_button = QToolButton(self.browser_box) self.back_button.setIconSet(QIconSet(Icons.load('Left2'))) self.back_button.setTextLabel('Back') self.back_button.setUsesTextLabel(True) self.back_button.setTextPosition(QToolButton.BelowIcon) self.back_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.forward_button = QToolButton(self.browser_box) self.forward_button.setIconSet(QIconSet(Icons.load('Right2'))) self.forward_button.setTextLabel('Forward') self.forward_button.setUsesTextLabel(True) self.forward_button.setTextPosition(QToolButton.BelowIcon) self.forward_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.top_layout.addWidget(self.back_button) self.top_layout.addWidget(self.forward_button) self.browser_box.layout().addLayout(self.top_layout) self.browser = QTextBrowser(self.browser_box) self.browser.setReadOnly(True) self.browser_box.layout().addWidget(self.browser) self.layout.addWidget(self.main_layout) #initially disabled self.forward_button.setEnabled(False) self.back_button.setEnabled(False) #connections QObject.connect(self.browser, SIGNAL('backwardAvailable(bool)'), self.back_button.setEnabled) QObject.connect(self.browser, SIGNAL('forwardAvailable(bool)'), self.forward_button.setEnabled) QObject.connect(self.back_button, SIGNAL('clicked()'), self.browser.backward) QObject.connect(self.forward_button, SIGNAL('clicked()'), self.browser.forward) self.edna = None # resize the splitter to something like 1/4-3/4 # width = self.main_layout.width() # left = width / 4.0 # right = width - left # logging.debug('setting splitter sizes to %d and %d', left, right) # self.main_layout.setSizes([left, right]) def sort_column(self, col_number): logging.debug('%s: sorting with column %d', self, col_number) if col_number == self.sort_column: # switch the sort order self.sort_order = self.sort_order ^ True else: self.sort_order = True #else, ascending self.sort_column = col_number self.history.sortColumn(col_number, self.sort_order, True) # put the right decoration on the header label if self.sort_order: direction = Qt.Ascending else: direction = Qt.Descending self.history.horizontalHeader().setSortIndicator(col_number, direction) def load_file(self, path): if self.browser.mimeSourceFactory().data(path) == None: self.browser.setText('<center>FILE NOT FOUND</center>') else: self.browser.setSource(abspath(path)) def history_changed(self, row, col): logging.debug('history elem selected: %d:%d', row, col) index = (str(self.history.text(row,0)), str(self.history.text(row,1)), str(self.history.text(row,2))) try: path = self.history_map[index] self.load_file(path) except KeyError as e: # can happen when qt sends us the signal with # null data and we get the key ("","","") pass def new_html(self, html_path, image_prefix, run_number): logging.getLogger().debug('got a new html page: %s, prefix: %r, run number: %s', html_path, image_prefix, run_number) # prepend the time and date to the path we just got so # the history is more readable time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) index = (time_string, str(image_prefix), str(run_number)) self.history_map[index] = html_path # synchronize the history prop if self.current_user is not None: whole_history = pickle.loads(self.getProperty('history').getValue()) whole_history[self.current_user] = self.history_map self.getProperty('history').setValue(pickle.dumps(whole_history)) self.history.insertRows(self.history.numRows()) logging.debug('numRows() is %d', self.history.numRows()) rows = self.history.numRows() - 1 self.history.setText(rows, 0, QString(time_string)) self.history.setText(rows, 1, QString(str(image_prefix))) self.history.setText(rows, 2, QString(str(run_number))) logging.debug('numRows() is %d', self.history.numRows()) self.load_file(html_path) def clear_history(self): self.history_map.clear() self.history.setNumRows(0) def propertyChanged(self, prop, oldval, newval): if prop == 'mnemonic': logging.getLogger().debug('BrowserBrick: using edna object %s', newval) if self.edna is not None: self.disconnect(self.edna, PYSIGNAL('newEDNAHTML'), self.new_html) self.edna = self.getHardwareObject(newval) logging.getLogger().debug('edna object is now: %s', self.edna) self.connect(self.edna, PYSIGNAL('newEDNAHTML'), self.new_html) def run(self): pass def login_changed(self, session_id,prop_code=None,prop_number=None,prop_id=None,expiration_time=0): logging.debug('BrowserBrick::login_changed: login changed to %r', session_id) if session_id is None: # user logged out logging.debug('user logged out') self.current_user = None else: self.current_user = (prop_code, prop_number) logging.debug('current user is now %r', self.current_user) self.clear_all() self.fill_history_for(self.current_user) def clear_all(self): self.clear_history() self.browser.setText('') def fill_history_for(self, user): if user is None: return logging.debug('loading history for user %s', user) whole_history = pickle.loads(self.getProperty('history').getValue()) try: self.history_map = whole_history[user] except KeyError: #user has no history yet self.history_map = dict() for k,v in self.history_map.items(): self.history.insertRows(self.history.numRows()) logging.debug('numRows() is %d', self.history.numRows()) rows = self.history.numRows() - 1 self.history.setText(rows, 0, k[0]) self.history.setText(rows, 1, k[1]) self.history.setText(rows, 2, k[2]) def cleanup_history(self): histories = pickle.loads(self.getProperty('history').getValue()) sessions_ttl = self.getProperty('sessions ttl (in days)').getValue() limit_date = datetime.now() - timedelta(sessions_ttl) #we're mutating the dict so do not use iteritems() just to be sure for user in list(histories.keys()): history = histories[user] #get the keys where the date is more recent than the limit date valid_keys = [x for x in list(history.keys()) if datetime.strptime(x[0], '%Y-%m-%d %H:%M:%S') > limit_date] #NB: old format was "%a, %d %b %Y %H:%M:%S" if len(valid_keys) != len(history): # some entries are too old, copy only the ones that are recent enough new_hist = dict((k,history[k]) for k in valid_keys) logging.debug('BrowserBrick: removed %d entries from saved history for user %s', len(history) - len(valid_keys), user) histories[user] = new_hist self.getProperty('history').setValue(pickle.dumps(histories))
class PluginSettingsUi(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) if not name: self.setName("PluginSettingsUi") self.setSizeGripEnabled(1) PluginSettingsUiLayout = QGridLayout(self,1,1,11,6,"PluginSettingsUiLayout") Layout1 = QHBoxLayout(None,0,6,"Layout1") Horizontal_Spacing2 = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum) Layout1.addItem(Horizontal_Spacing2) self.bt_ok = QPushButton(self,"bt_ok") self.bt_ok.setAutoDefault(1) self.bt_ok.setDefault(1) Layout1.addWidget(self.bt_ok) self.bt_cancel = QPushButton(self,"bt_cancel") self.bt_cancel.setAutoDefault(1) Layout1.addWidget(self.bt_cancel) PluginSettingsUiLayout.addMultiCellLayout(Layout1,1,1,0,1) self.lw_plugins = QListView(self,"lw_plugins") self.lw_plugins.addColumn(self.__tr("Plugin")) self.lw_plugins.header().setClickEnabled(0,self.lw_plugins.header().count() - 1) self.lw_plugins.setMinimumSize(QSize(300,0)) self.lw_plugins.setMaximumSize(QSize(300,32767)) self.lw_plugins.setResizePolicy(QListView.AutoOneFit) self.lw_plugins.setResizeMode(QListView.LastColumn) PluginSettingsUiLayout.addWidget(self.lw_plugins,0,0) self.frame3 = QFrame(self,"frame3") self.frame3.setMinimumSize(QSize(330,0)) self.frame3.setFrameShape(QFrame.StyledPanel) self.frame3.setFrameShadow(QFrame.Raised) frame3Layout = QGridLayout(self.frame3,1,1,11,6,"frame3Layout") self.line1 = QFrame(self.frame3,"line1") self.line1.setFrameShape(QFrame.HLine) self.line1.setFrameShadow(QFrame.Sunken) self.line1.setFrameShape(QFrame.HLine) frame3Layout.addWidget(self.line1,3,0) self.t_parameters = QTable(self.frame3,"t_parameters") self.t_parameters.setSelectionMode(QTable.NoSelection) self.t_parameters.setNumCols(self.t_parameters.numCols() + 1) self.t_parameters.horizontalHeader().setLabel(self.t_parameters.numCols() - 1,self.__tr("Value")) self.t_parameters.horizontalHeader().setClickEnabled(False) self.t_parameters.setNumRows(self.t_parameters.numRows() + 1) self.t_parameters.verticalHeader().setLabel(self.t_parameters.numRows() - 1,self.__tr("Default ")) self.t_parameters.setMinimumSize(QSize(300,0)) self.t_parameters.setResizePolicy(QTable.Default) self.t_parameters.setVScrollBarMode(QTable.AlwaysOn) self.t_parameters.setNumRows(1) self.t_parameters.setNumCols(1) self.t_parameters.setSorting(1) frame3Layout.addWidget(self.t_parameters,3,0) layout5 = QHBoxLayout(None,0,6,"layout5") self.label_name = QLabel(self.frame3,"label_name") self.label_name.setMinimumSize(QSize(67,0)) self.label_name.setMaximumSize(QSize(67,32767)) label_name_font = QFont(self.label_name.font()) label_name_font.setBold(1) self.label_name.setFont(label_name_font) layout5.addWidget(self.label_name) self.le_name = QLineEdit(self.frame3,"le_name") self.le_name.setMinimumSize(QSize(250,0)) self.le_name.setReadOnly(1) layout5.addWidget(self.le_name) frame3Layout.addLayout(layout5,0,0) layout6 = QHBoxLayout(None,0,6,"layout6") self.label_version = QLabel(self.frame3,"label_version") self.label_version.setMinimumSize(QSize(67,0)) self.label_version.setMaximumSize(QSize(67,32767)) label_version_font = QFont(self.label_version.font()) label_version_font.setBold(1) self.label_version.setFont(label_version_font) layout6.addWidget(self.label_version) self.le_version = QLineEdit(self.frame3,"le_version") self.le_version.setMinimumSize(QSize(250,0)) self.le_version.setReadOnly(1) layout6.addWidget(self.le_version) frame3Layout.addLayout(layout6,1,0) layout7 = QHBoxLayout(None,0,6,"layout7") self.label_pversion = QLabel(self.frame3,"label_pversion") self.label_pversion.setMinimumSize(QSize(67,0)) self.label_pversion.setMaximumSize(QSize(67,32767)) label_pversion_font = QFont(self.label_pversion.font()) label_pversion_font.setBold(1) self.label_pversion.setFont(label_pversion_font) layout7.addWidget(self.label_pversion) self.le_pversion = QLineEdit(self.frame3,"le_pversion") self.le_pversion.setMinimumSize(QSize(250,0)) self.le_pversion.setReadOnly(1) layout7.addWidget(self.le_pversion) frame3Layout.addLayout(layout7,2,0) PluginSettingsUiLayout.addWidget(self.frame3,0,1) self.languageChange() self.resize(QSize(782,593).expandedTo(self.minimumSizeHint())) self.clearWState(Qt.WState_Polished) self.connect(self.bt_ok,SIGNAL("clicked()"),self.accept) self.connect(self.bt_cancel,SIGNAL("clicked()"),self.reject) def languageChange(self): self.setCaption(self.__tr("Plugin Settings")) self.bt_ok.setText(self.__tr("&OK")) self.bt_ok.setAccel(QKeySequence(QString.null)) self.bt_cancel.setText(self.__tr("&Cancel")) self.bt_cancel.setAccel(QKeySequence(QString.null)) self.lw_plugins.header().setLabel(0,self.__tr("Plugin")) self.t_parameters.horizontalHeader().setLabel(0,self.__tr("Value")) self.t_parameters.verticalHeader().setLabel(0,self.__tr("Default ")) self.label_name.setText(self.__tr("Name:")) self.label_version.setText(self.__tr("Tool:")) self.label_pversion.setText(self.__tr("Plugin:")) def lv_parameters_currentChanged(self,a0): devlog("PluginSettingsUi.lv_parameters_currentChanged(QListViewItem*): Not implemented yet") def __tr(self,s,c = None): return qApp.translate("PluginSettingsUi",s,c)
class BrowserBrick(BaseComponents.BlissWidget): def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) #map displayed string in the history list -> actual file path self.history_map = dict() self.layout = QVBoxLayout(self) self.defineSlot('load_file', ()) self.defineSlot('login_changed', ()) self.addProperty('mnemonic', 'string', '') self.addProperty('history', 'string', '', hidden=True) self.addProperty('sessions ttl (in days)', 'integer', '30') #make sure the history property is a pickled dict try: hist = pickle.loads(self.getProperty('history').getValue()) except: # EOFError if the string is empty but let's not count on it self.getProperty('history').setValue(pickle.dumps(dict())) # maybe defer that for later self.cleanup_history() self.main_layout = QSplitter(self) self.main_layout.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) # left part of the splitter self.history_box = QVBox(self.main_layout) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.sort_order = True self.sort_col = None self.history = QTable(self.history_box) self.history.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)) self.history.setSelectionMode(QTable.SingleRow) self.history.setNumCols(3) self.history.verticalHeader().hide() self.history.setLeftMargin(0) self.history.setSorting(False) QObject.connect(self.history, SIGNAL('currentChanged(int,int)'), self.history_changed) #by default sorting only sorts the columns and not whole rows. #let's reimplement that QObject.connect(self.history.horizontalHeader(), SIGNAL('clicked(int)'), self.sort_column) header = self.history.horizontalHeader() header.setLabel(0, 'Time and date') header.setLabel(1, 'Prefix') header.setLabel(2, 'Run number') self.clear_history_button = QPushButton('Clear history', self.history_box) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) QObject.connect(self.clear_history_button, SIGNAL('clicked()'), self.clear_history) # Right part of the splitter self.browser_box = QWidget(self.main_layout) QVBoxLayout(self.browser_box) self.browser_box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.top_layout = QHBoxLayout(self.browser_box) self.back_button = QToolButton(self.browser_box) self.back_button.setIconSet(QIconSet(Icons.load('Left2'))) self.back_button.setTextLabel('Back') self.back_button.setUsesTextLabel(True) self.back_button.setTextPosition(QToolButton.BelowIcon) self.back_button.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.forward_button = QToolButton(self.browser_box) self.forward_button.setIconSet(QIconSet(Icons.load('Right2'))) self.forward_button.setTextLabel('Forward') self.forward_button.setUsesTextLabel(True) self.forward_button.setTextPosition(QToolButton.BelowIcon) self.forward_button.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.top_layout.addWidget(self.back_button) self.top_layout.addWidget(self.forward_button) self.browser_box.layout().addLayout(self.top_layout) self.browser = QTextBrowser(self.browser_box) self.browser.setReadOnly(True) self.browser_box.layout().addWidget(self.browser) self.layout.addWidget(self.main_layout) #initially disabled self.forward_button.setEnabled(False) self.back_button.setEnabled(False) #connections QObject.connect(self.browser, SIGNAL('backwardAvailable(bool)'), self.back_button.setEnabled) QObject.connect(self.browser, SIGNAL('forwardAvailable(bool)'), self.forward_button.setEnabled) QObject.connect(self.back_button, SIGNAL('clicked()'), self.browser.backward) QObject.connect(self.forward_button, SIGNAL('clicked()'), self.browser.forward) self.edna = None # resize the splitter to something like 1/4-3/4 # width = self.main_layout.width() # left = width / 4.0 # right = width - left # logging.debug('setting splitter sizes to %d and %d', left, right) # self.main_layout.setSizes([left, right]) def sort_column(self, col_number): logging.debug('%s: sorting with column %d', self, col_number) if col_number == self.sort_column: # switch the sort order self.sort_order = self.sort_order ^ True else: self.sort_order = True #else, ascending self.sort_column = col_number self.history.sortColumn(col_number, self.sort_order, True) # put the right decoration on the header label if self.sort_order: direction = Qt.Ascending else: direction = Qt.Descending self.history.horizontalHeader().setSortIndicator(col_number, direction) def load_file(self, path): if self.browser.mimeSourceFactory().data(path) == None: self.browser.setText('<center>FILE NOT FOUND</center>') else: self.browser.setSource(abspath(path)) def history_changed(self, row, col): logging.debug('history elem selected: %d:%d', row, col) index = (str(self.history.text(row, 0)), str(self.history.text(row, 1)), str(self.history.text(row, 2))) try: path = self.history_map[index] self.load_file(path) except KeyError as e: # can happen when qt sends us the signal with # null data and we get the key ("","","") pass def new_html(self, html_path, image_prefix, run_number): logging.getLogger().debug( 'got a new html page: %s, prefix: %r, run number: %s', html_path, image_prefix, run_number) # prepend the time and date to the path we just got so # the history is more readable time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) index = (time_string, str(image_prefix), str(run_number)) self.history_map[index] = html_path # synchronize the history prop if self.current_user is not None: whole_history = pickle.loads( self.getProperty('history').getValue()) whole_history[self.current_user] = self.history_map self.getProperty('history').setValue(pickle.dumps(whole_history)) self.history.insertRows(self.history.numRows()) logging.debug('numRows() is %d', self.history.numRows()) rows = self.history.numRows() - 1 self.history.setText(rows, 0, QString(time_string)) self.history.setText(rows, 1, QString(str(image_prefix))) self.history.setText(rows, 2, QString(str(run_number))) logging.debug('numRows() is %d', self.history.numRows()) self.load_file(html_path) def clear_history(self): self.history_map.clear() self.history.setNumRows(0) def propertyChanged(self, prop, oldval, newval): if prop == 'mnemonic': logging.getLogger().debug('BrowserBrick: using edna object %s', newval) if self.edna is not None: self.disconnect(self.edna, PYSIGNAL('newEDNAHTML'), self.new_html) self.edna = self.getHardwareObject(newval) logging.getLogger().debug('edna object is now: %s', self.edna) self.connect(self.edna, PYSIGNAL('newEDNAHTML'), self.new_html) def run(self): pass def login_changed(self, session_id, prop_code=None, prop_number=None, prop_id=None, expiration_time=0): logging.debug('BrowserBrick::login_changed: login changed to %r', session_id) if session_id is None: # user logged out logging.debug('user logged out') self.current_user = None else: self.current_user = (prop_code, prop_number) logging.debug('current user is now %r', self.current_user) self.clear_all() self.fill_history_for(self.current_user) def clear_all(self): self.clear_history() self.browser.setText('') def fill_history_for(self, user): if user is None: return logging.debug('loading history for user %s', user) whole_history = pickle.loads(self.getProperty('history').getValue()) try: self.history_map = whole_history[user] except KeyError: #user has no history yet self.history_map = dict() for k, v in self.history_map.items(): self.history.insertRows(self.history.numRows()) logging.debug('numRows() is %d', self.history.numRows()) rows = self.history.numRows() - 1 self.history.setText(rows, 0, k[0]) self.history.setText(rows, 1, k[1]) self.history.setText(rows, 2, k[2]) def cleanup_history(self): histories = pickle.loads(self.getProperty('history').getValue()) sessions_ttl = self.getProperty('sessions ttl (in days)').getValue() limit_date = datetime.now() - timedelta(sessions_ttl) #we're mutating the dict so do not use iteritems() just to be sure for user in list(histories.keys()): history = histories[user] #get the keys where the date is more recent than the limit date valid_keys = [ x for x in list(history.keys()) if datetime.strptime(x[0], '%Y-%m-%d %H:%M:%S') > limit_date ] #NB: old format was "%a, %d %b %Y %H:%M:%S" if len(valid_keys) != len(history): # some entries are too old, copy only the ones that are recent enough new_hist = dict((k, history[k]) for k in valid_keys) logging.debug( 'BrowserBrick: removed %d entries from saved history for user %s', len(history) - len(valid_keys), user) histories[user] = new_hist self.getProperty('history').setValue(pickle.dumps(histories))
class QtResultBrowseUi(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) if not name: self.setName("QtResultBrowseUi") QtResultBrowseUiLayout = QGridLayout(self,1,1,11,6,"QtResultBrowseUiLayout") self.splitter5 = QSplitter(self,"splitter5") self.splitter5.setOrientation(QSplitter.Vertical) self.splitter4 = QSplitter(self.splitter5,"splitter4") self.splitter4.setOrientation(QSplitter.Horizontal) self.tblValues = QTable(self.splitter4,"tblValues") self.tblValues.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding,0,0,self.tblValues.sizePolicy().hasHeightForWidth())) tblValues_font = QFont(self.tblValues.font()) tblValues_font.setFamily("Lucida Sans Typewriter") self.tblValues.setFont(tblValues_font) self.tblValues.setResizePolicy(QTable.Default) self.tblValues.setNumRows(23) self.tblValues.setNumCols(7) self.tblValues.setSorting(0) self.tabWidget2 = QTabWidget(self.splitter4,"tabWidget2") self.tab = QWidget(self.tabWidget2,"tab") tabLayout = QGridLayout(self.tab,1,1,11,6,"tabLayout") self.tblDetails = QTable(self.tab,"tblDetails") tblDetails_font = QFont(self.tblDetails.font()) tblDetails_font.setFamily("Lucida Sans Typewriter") self.tblDetails.setFont(tblDetails_font) self.tblDetails.setNumRows(3) self.tblDetails.setNumCols(3) tabLayout.addWidget(self.tblDetails,0,0) self.tabWidget2.insertTab(self.tab,QString.fromLatin1("")) self.TabPage = QWidget(self.tabWidget2,"TabPage") TabPageLayout = QGridLayout(self.TabPage,1,1,11,6,"TabPageLayout") self.txtPointSummary = QTextEdit(self.TabPage,"txtPointSummary") txtPointSummary_font = QFont(self.txtPointSummary.font()) txtPointSummary_font.setFamily("Lucida Sans Typewriter") self.txtPointSummary.setFont(txtPointSummary_font) self.txtPointSummary.setWordWrap(QTextEdit.NoWrap) TabPageLayout.addWidget(self.txtPointSummary,0,0) self.tabWidget2.insertTab(self.TabPage,QString.fromLatin1("")) self.tab_2 = QWidget(self.tabWidget2,"tab_2") tabLayout_2 = QVBoxLayout(self.tab_2,11,6,"tabLayout_2") self.txtNetlist = QTextEdit(self.tab_2,"txtNetlist") txtNetlist_font = QFont(self.txtNetlist.font()) txtNetlist_font.setFamily("Lucida Sans Typewriter") self.txtNetlist.setFont(txtNetlist_font) self.txtNetlist.setWordWrap(QTextEdit.NoWrap) tabLayout_2.addWidget(self.txtNetlist) layout3 = QHBoxLayout(None,0,6,"layout3") self.chkBlockInfo = QCheckBox(self.tab_2,"chkBlockInfo") layout3.addWidget(self.chkBlockInfo) self.chkInfoString = QCheckBox(self.tab_2,"chkInfoString") layout3.addWidget(self.chkInfoString) tabLayout_2.addLayout(layout3) self.tabWidget2.insertTab(self.tab_2,QString.fromLatin1("")) self.TabPage_2 = QWidget(self.tabWidget2,"TabPage_2") TabPageLayout_2 = QVBoxLayout(self.TabPage_2,11,6,"TabPageLayout_2") self.txtIndString = QTextEdit(self.TabPage_2,"txtIndString") txtIndString_font = QFont(self.txtIndString.font()) txtIndString_font.setFamily("Lucida Sans Typewriter") self.txtIndString.setFont(txtIndString_font) self.txtIndString.setWordWrap(QTextEdit.WidgetWidth) self.txtIndString.setWrapPolicy(QTextEdit.AtWordBoundary) TabPageLayout_2.addWidget(self.txtIndString) self.tabWidget2.insertTab(self.TabPage_2,QString.fromLatin1("")) self.TabPage_3 = QWidget(self.tabWidget2,"TabPage_3") TabPageLayout_3 = QVBoxLayout(self.TabPage_3,11,6,"TabPageLayout_3") self.matplotlibWidget1 = MatplotlibWidget(self.TabPage_3,"matplotlibWidget1") self.matplotlibWidget1.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred,0,0,self.matplotlibWidget1.sizePolicy().hasHeightForWidth())) TabPageLayout_3.addWidget(self.matplotlibWidget1) self.groupBox3 = QGroupBox(self.TabPage_3,"groupBox3") self.groupBox3.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Maximum,0,0,self.groupBox3.sizePolicy().hasHeightForWidth())) self.groupBox3.setColumnLayout(0,Qt.Vertical) self.groupBox3.layout().setSpacing(6) self.groupBox3.layout().setMargin(11) groupBox3Layout = QGridLayout(self.groupBox3.layout()) groupBox3Layout.setAlignment(Qt.AlignTop) layout10 = QGridLayout(None,1,1,0,6,"layout10") self.textLabel1_2 = QLabel(self.groupBox3,"textLabel1_2") self.textLabel1_2.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Preferred,0,0,self.textLabel1_2.sizePolicy().hasHeightForWidth())) layout10.addWidget(self.textLabel1_2,1,0) self.cmbXAxis = QComboBox(0,self.groupBox3,"cmbXAxis") layout10.addWidget(self.cmbXAxis,0,1) self.textLabel1 = QLabel(self.groupBox3,"textLabel1") self.textLabel1.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Preferred,0,0,self.textLabel1.sizePolicy().hasHeightForWidth())) layout10.addWidget(self.textLabel1,0,0) self.cmbYAxis = QComboBox(0,self.groupBox3,"cmbYAxis") layout10.addWidget(self.cmbYAxis,1,1) groupBox3Layout.addMultiCellLayout(layout10,0,0,0,1) layout21 = QVBoxLayout(None,0,6,"layout21") layout19 = QHBoxLayout(None,0,6,"layout19") self.chkHoldPlot = QCheckBox(self.groupBox3,"chkHoldPlot") layout19.addWidget(self.chkHoldPlot) self.txtPlotFormatString = QLineEdit(self.groupBox3,"txtPlotFormatString") layout19.addWidget(self.txtPlotFormatString) layout21.addLayout(layout19) layout18 = QHBoxLayout(None,0,6,"layout18") self.chkTopoPlot = QCheckBox(self.groupBox3,"chkTopoPlot") layout18.addWidget(self.chkTopoPlot) layout15 = QHBoxLayout(None,0,6,"layout15") self.txtTopoMask = QLineEdit(self.groupBox3,"txtTopoMask") layout15.addWidget(self.txtTopoMask) self.txtTopoFilter = QLineEdit(self.groupBox3,"txtTopoFilter") layout15.addWidget(self.txtTopoFilter) layout18.addLayout(layout15) layout21.addLayout(layout18) layout17 = QHBoxLayout(None,0,6,"layout17") self.chkClustering = QCheckBox(self.groupBox3,"chkClustering") layout17.addWidget(self.chkClustering) self.chkFrontOnly = QCheckBox(self.groupBox3,"chkFrontOnly") layout17.addWidget(self.chkFrontOnly) self.chkNonFront = QCheckBox(self.groupBox3,"chkNonFront") layout17.addWidget(self.chkNonFront) layout21.addLayout(layout17) groupBox3Layout.addLayout(layout21,1,0) layout20 = QVBoxLayout(None,0,6,"layout20") self.btnUpdatePlot = QPushButton(self.groupBox3,"btnUpdatePlot") layout20.addWidget(self.btnUpdatePlot) self.btnClearPlot = QPushButton(self.groupBox3,"btnClearPlot") layout20.addWidget(self.btnClearPlot) self.btnSaveData = QPushButton(self.groupBox3,"btnSaveData") layout20.addWidget(self.btnSaveData) groupBox3Layout.addLayout(layout20,1,1) TabPageLayout_3.addWidget(self.groupBox3) self.tabWidget2.insertTab(self.TabPage_3,QString.fromLatin1("")) self.splitter4_2 = QSplitter(self.splitter5,"splitter4_2") self.splitter4_2.setOrientation(QSplitter.Horizontal) LayoutWidget = QWidget(self.splitter4_2,"layout20") layout20_2 = QVBoxLayout(LayoutWidget,11,6,"layout20_2") layout16 = QHBoxLayout(None,0,6,"layout16") self.btnSort = QPushButton(LayoutWidget,"btnSort") layout16.addWidget(self.btnSort) spacer4 = QSpacerItem(161,21,QSizePolicy.Expanding,QSizePolicy.Minimum) layout16.addItem(spacer4) layout20_2.addLayout(layout16) layout19_2 = QHBoxLayout(None,0,6,"layout19_2") self.btnIndEdit = QPushButton(LayoutWidget,"btnIndEdit") layout19_2.addWidget(self.btnIndEdit) spacer4_2 = QSpacerItem(250,21,QSizePolicy.Expanding,QSizePolicy.Minimum) layout19_2.addItem(spacer4_2) self.btnSheetSaveAs = QPushButton(LayoutWidget,"btnSheetSaveAs") layout19_2.addWidget(self.btnSheetSaveAs) self.btnIndSaveAs = QPushButton(LayoutWidget,"btnIndSaveAs") layout19_2.addWidget(self.btnIndSaveAs) layout20_2.addLayout(layout19_2) spacer5 = QSpacerItem(20,106,QSizePolicy.Minimum,QSizePolicy.Expanding) layout20_2.addItem(spacer5) self.groupBox3_2 = QGroupBox(LayoutWidget,"groupBox3_2") self.groupBox3_2.setColumnLayout(0,Qt.Vertical) self.groupBox3_2.layout().setSpacing(6) self.groupBox3_2.layout().setMargin(11) groupBox3_2Layout = QVBoxLayout(self.groupBox3_2.layout()) groupBox3_2Layout.setAlignment(Qt.AlignTop) layout14 = QHBoxLayout(None,0,6,"layout14") self.chkNondom = QCheckBox(self.groupBox3_2,"chkNondom") self.chkNondom.setChecked(1) layout14.addWidget(self.chkNondom) self.chkFeasible = QCheckBox(self.groupBox3_2,"chkFeasible") self.chkFeasible.setChecked(1) layout14.addWidget(self.chkFeasible) groupBox3_2Layout.addLayout(layout14) layout20_3 = QHBoxLayout(None,0,6,"layout20_3") self.chkAgeLayer = QCheckBox(self.groupBox3_2,"chkAgeLayer") layout20_3.addWidget(self.chkAgeLayer) self.chkAddLowerLayer = QCheckBox(self.groupBox3_2,"chkAddLowerLayer") layout20_3.addWidget(self.chkAddLowerLayer) self.spinAgeLayer = QSpinBox(self.groupBox3_2,"spinAgeLayer") layout20_3.addWidget(self.spinAgeLayer) groupBox3_2Layout.addLayout(layout20_3) layout20_4 = QHBoxLayout(None,0,6,"layout20_4") self.textLabel1_3 = QLabel(self.groupBox3_2,"textLabel1_3") layout20_4.addWidget(self.textLabel1_3) self.txtListTopoFilter = QLineEdit(self.groupBox3_2,"txtListTopoFilter") layout20_4.addWidget(self.txtListTopoFilter) self.btnUpdateListTopoFilter = QPushButton(self.groupBox3_2,"btnUpdateListTopoFilter") layout20_4.addWidget(self.btnUpdateListTopoFilter) groupBox3_2Layout.addLayout(layout20_4) layout20_2.addWidget(self.groupBox3_2) LayoutWidget_2 = QWidget(self.splitter4_2,"layout17") layout17_2 = QHBoxLayout(LayoutWidget_2,11,6,"layout17_2") layout16_2 = QVBoxLayout(None,0,6,"layout16_2") self.btnUpdate = QPushButton(LayoutWidget_2,"btnUpdate") layout16_2.addWidget(self.btnUpdate) spacer3 = QSpacerItem(20,110,QSizePolicy.Minimum,QSizePolicy.Expanding) layout16_2.addItem(spacer3) self.btnCloseAll = QPushButton(LayoutWidget_2,"btnCloseAll") layout16_2.addWidget(self.btnCloseAll) self.btnClose = QPushButton(LayoutWidget_2,"btnClose") layout16_2.addWidget(self.btnClose) self.btnSave = QPushButton(LayoutWidget_2,"btnSave") layout16_2.addWidget(self.btnSave) self.btnLoad = QPushButton(LayoutWidget_2,"btnLoad") self.btnLoad.setDefault(1) layout16_2.addWidget(self.btnLoad) layout17_2.addLayout(layout16_2) layout12 = QVBoxLayout(None,0,6,"layout12") self.lstOpenStates = QListBox(LayoutWidget_2,"lstOpenStates") layout12.addWidget(self.lstOpenStates) layout11 = QHBoxLayout(None,0,6,"layout11") self.textLabel2 = QLabel(LayoutWidget_2,"textLabel2") layout11.addWidget(self.textLabel2) self.txtFilename = QLineEdit(LayoutWidget_2,"txtFilename") self.txtFilename.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed,0,0,self.txtFilename.sizePolicy().hasHeightForWidth())) layout11.addWidget(self.txtFilename) self.btnOpenFile = QPushButton(LayoutWidget_2,"btnOpenFile") self.btnOpenFile.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Fixed,0,0,self.btnOpenFile.sizePolicy().hasHeightForWidth())) self.btnOpenFile.setMaximumSize(QSize(30,32767)) layout11.addWidget(self.btnOpenFile) layout12.addLayout(layout11) layout17_2.addLayout(layout12) QtResultBrowseUiLayout.addWidget(self.splitter5,0,0) self.languageChange() self.resize(QSize(1299,877).expandedTo(self.minimumSizeHint())) self.clearWState(Qt.WState_Polished) def languageChange(self): self.setCaption(self.__tr("Form1")) self.tabWidget2.changeTab(self.tab,self.__tr("Point")) self.tabWidget2.changeTab(self.TabPage,self.__tr("PointSummary")) self.chkBlockInfo.setText(self.__tr("Block Info")) self.chkInfoString.setText(self.__tr("Info String")) self.tabWidget2.changeTab(self.tab_2,self.__tr("Netlist")) self.tabWidget2.changeTab(self.TabPage_2,self.__tr("Ind")) self.groupBox3.setTitle(self.__tr("Options")) self.textLabel1_2.setText(self.__tr("Y-Axis")) self.textLabel1.setText(self.__tr("X-Axis")) self.chkHoldPlot.setText(self.__tr("Hold plots")) self.txtPlotFormatString.setText(self.__tr(".")) QToolTip.add(self.txtPlotFormatString,self.__tr("Format string")) self.chkTopoPlot.setText(self.__tr("Topo plot")) QToolTip.add(self.txtTopoMask,self.__tr("topo mask")) QToolTip.add(self.txtTopoFilter,self.__tr("topo filter")) self.chkClustering.setText(self.__tr("Show clustering")) self.chkFrontOnly.setText(self.__tr("Front only")) self.chkNonFront.setText(self.__tr("Non-front")) self.btnUpdatePlot.setText(self.__tr("Plot")) self.btnClearPlot.setText(self.__tr("Clear Plot")) self.btnSaveData.setText(self.__tr("Save data")) self.tabWidget2.changeTab(self.TabPage_3,self.__tr("Plot")) self.btnSort.setText(self.__tr("Sort")) self.btnIndEdit.setText(self.__tr("Edit Ind")) self.btnSheetSaveAs.setText(self.__tr("Save Sheet as")) self.btnIndSaveAs.setText(self.__tr("Save Ind As")) self.groupBox3_2.setTitle(self.__tr("Set selection")) self.chkNondom.setText(self.__tr("Non dominated only")) self.chkFeasible.setText(self.__tr("Feasible only")) self.chkAgeLayer.setText(self.__tr("Age layer")) self.chkAddLowerLayer.setText(self.__tr("Include one lower layer")) self.textLabel1_3.setText(self.__tr("Topology filter")) QToolTip.add(self.txtListTopoFilter,self.__tr("topo filter")) self.btnUpdateListTopoFilter.setText(self.__tr("Update")) self.btnUpdate.setText(self.__tr("update")) self.btnCloseAll.setText(self.__tr("Close all")) self.btnClose.setText(self.__tr("Close")) self.btnSave.setText(self.__tr("Save")) self.btnLoad.setText(self.__tr("Load")) self.textLabel2.setText(self.__tr("Filename:")) self.btnOpenFile.setText(self.__tr("...")) def __tr(self,s,c = None): return qApp.translate("QtResultBrowseUi",s,c)
class BrowserBrick(BaseComponents.BlissWidget): def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) #map displayed string in the history list -> actual file path self.history_map = dict() self.layout = QVBoxLayout(self) self.defineSlot('load_file', ()) self.defineSlot('login_changed', ()) self.addProperty('mnemonic', 'string', '') self.addProperty('history', 'string', '', hidden=True) self.addProperty('sessions ttl (in days)', 'integer', '30') #make sure the history property is a pickled dict try: hist = pickle.loads(self.getProperty('history').getValue()) except: # EOFError if the string is empty but let's not count on it self.getProperty('history').setValue(pickle.dumps(dict())) # maybe defer that for later self.cleanup_history() self.main_layout = QSplitter(self) self.main_layout.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) # left part of the splitter self.history_box = QVBox(self.main_layout) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.sort_order = True self.sort_col = None self.history = QTable(self.history_box) self.history.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)) self.history.setSelectionMode(QTable.SingleRow) self.history.setNumCols(3) self.history.verticalHeader().hide() self.history.setLeftMargin(0) self.history.setSorting(False) QObject.connect(self.history, SIGNAL('currentChanged(int,int)'), self.history_changed) #by default sorting only sorts the columns and not whole rows. #let's reimplement that QObject.connect(self.history.horizontalHeader(), SIGNAL('clicked(int)'), self.sort_column) header = self.history.horizontalHeader() header.setLabel(0, 'Time and date') header.setLabel(1, 'Prefix') header.setLabel(2, 'Run number') self.clear_history_button = QPushButton('Clear history', self.history_box) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) QObject.connect(self.clear_history_button, SIGNAL('clicked()'), self.clear_history) # Right part of the splitter self.browser_box = QWidget(self.main_layout) QVBoxLayout(self.browser_box) self.browser_box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.top_layout = QHBoxLayout(self.browser_box) self.back_button = QToolButton(self.browser_box) self.back_button.setIconSet(QIconSet(Icons.load('Left2'))) self.back_button.setTextLabel('Back') self.back_button.setUsesTextLabel(True) self.back_button.setTextPosition(QToolButton.BelowIcon) self.back_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.forward_button = QToolButton(self.browser_box) self.forward_button.setIconSet(QIconSet(Icons.load('Right2'))) self.forward_button.setTextLabel('Forward') self.forward_button.setUsesTextLabel(True) self.forward_button.setTextPosition(QToolButton.BelowIcon) self.forward_button.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.top_layout.addWidget(self.back_button) self.top_layout.addWidget(self.forward_button) self.browser_box.layout().addLayout(self.top_layout) self.browser = QTextBrowser(self.browser_box) self.browser.setReadOnly(True) self.browser_box.layout().addWidget(self.browser) self.layout.addWidget(self.main_layout) #initially disabled self.forward_button.setEnabled(False) self.back_button.setEnabled(False) #connections QObject.connect(self.browser, SIGNAL('backwardAvailable(bool)'), self.back_button.setEnabled) QObject.connect(self.browser, SIGNAL('forwardAvailable(bool)'), self.forward_button.setEnabled) QObject.connect(self.back_button, SIGNAL('clicked()'), self.browser.backward) QObject.connect(self.forward_button, SIGNAL('clicked()'), self.browser.forward) self.edna = None # resize the splitter to something like 1/4-3/4 # width = self.main_layout.width() # left = width / 4.0 # right = width - left # logging.debug('setting splitter sizes to %d and %d', left, right) # self.main_layout.setSizes([left, right]) def sort_column(self, col_number): logging.debug('%s: sorting with column %d', self, col_number) if col_number == self.sort_column: # switch the sort order self.sort_order = self.sort_order ^ True else: self.sort_order = True #else, ascending self.sort_column = col_number self.history.sortColumn(col_number, self.sort_order, True) # put the right decoration on the header label if self.sort_order: direction = Qt.Ascending else: direction = Qt.Descending self.history.horizontalHeader().setSortIndicator(col_number, direction) def load_file(self, path): if self.browser.mimeSourceFactory().data(path) == None: self.browser.setText('<center>FILE NOT FOUND</center>') else: self.browser.setSource(abspath(path)) def history_changed(self, row, col): logging.debug('history elem selected: %d:%d', row, col) index = (str(self.history.text(row,0)), str(self.history.text(row,1)), str(self.history.text(row,2))) try: path = self.history_map[index] self.load_file(path) except KeyError, e: # can happen when qt sends us the signal with # null data and we get the key ("","","") pass
class BrowserBrick(BaseComponents.BlissWidget): def __init__(self, *args): BaseComponents.BlissWidget.__init__(self, *args) #map displayed string in the history list -> actual file path self.history_map = dict() self.layout = QVBoxLayout(self) self.defineSlot('load_file', ()) self.defineSlot('login_changed', ()) self.addProperty('mnemonic', 'string', '') self.addProperty('history', 'string', '', hidden=True) self.addProperty('sessions ttl (in days)', 'integer', '30') #make sure the history property is a pickled dict try: hist = pickle.loads(self.getProperty('history').getValue()) except: # EOFError if the string is empty but let's not count on it self.getProperty('history').setValue(pickle.dumps(dict())) # maybe defer that for later self.cleanup_history() self.main_layout = QSplitter(self) self.main_layout.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) # left part of the splitter self.history_box = QVBox(self.main_layout) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.sort_order = True self.sort_col = None self.history = QTable(self.history_box) self.history.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)) self.history.setSelectionMode(QTable.SingleRow) self.history.setNumCols(3) self.history.verticalHeader().hide() self.history.setLeftMargin(0) self.history.setSorting(False) QObject.connect(self.history, SIGNAL('currentChanged(int,int)'), self.history_changed) #by default sorting only sorts the columns and not whole rows. #let's reimplement that QObject.connect(self.history.horizontalHeader(), SIGNAL('clicked(int)'), self.sort_column) header = self.history.horizontalHeader() header.setLabel(0, 'Time and date') header.setLabel(1, 'Prefix') header.setLabel(2, 'Run number') self.clear_history_button = QPushButton('Clear history', self.history_box) self.history_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) QObject.connect(self.clear_history_button, SIGNAL('clicked()'), self.clear_history) # Right part of the splitter self.browser_box = QWidget(self.main_layout) QVBoxLayout(self.browser_box) self.browser_box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.top_layout = QHBoxLayout(self.browser_box) self.back_button = QToolButton(self.browser_box) self.back_button.setIconSet(QIconSet(Icons.load('Left2'))) self.back_button.setTextLabel('Back') self.back_button.setUsesTextLabel(True) self.back_button.setTextPosition(QToolButton.BelowIcon) self.back_button.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.forward_button = QToolButton(self.browser_box) self.forward_button.setIconSet(QIconSet(Icons.load('Right2'))) self.forward_button.setTextLabel('Forward') self.forward_button.setUsesTextLabel(True) self.forward_button.setTextPosition(QToolButton.BelowIcon) self.forward_button.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.top_layout.addWidget(self.back_button) self.top_layout.addWidget(self.forward_button) self.browser_box.layout().addLayout(self.top_layout) self.browser = QTextBrowser(self.browser_box) self.browser.setReadOnly(True) self.browser_box.layout().addWidget(self.browser) self.layout.addWidget(self.main_layout) #initially disabled self.forward_button.setEnabled(False) self.back_button.setEnabled(False) #connections QObject.connect(self.browser, SIGNAL('backwardAvailable(bool)'), self.back_button.setEnabled) QObject.connect(self.browser, SIGNAL('forwardAvailable(bool)'), self.forward_button.setEnabled) QObject.connect(self.back_button, SIGNAL('clicked()'), self.browser.backward) QObject.connect(self.forward_button, SIGNAL('clicked()'), self.browser.forward) self.edna = None # resize the splitter to something like 1/4-3/4 # width = self.main_layout.width() # left = width / 4.0 # right = width - left # logging.debug('setting splitter sizes to %d and %d', left, right) # self.main_layout.setSizes([left, right]) def sort_column(self, col_number): logging.debug('%s: sorting with column %d', self, col_number) if col_number == self.sort_column: # switch the sort order self.sort_order = self.sort_order ^ True else: self.sort_order = True #else, ascending self.sort_column = col_number self.history.sortColumn(col_number, self.sort_order, True) # put the right decoration on the header label if self.sort_order: direction = Qt.Ascending else: direction = Qt.Descending self.history.horizontalHeader().setSortIndicator(col_number, direction) def load_file(self, path): if self.browser.mimeSourceFactory().data(path) == None: self.browser.setText('<center>FILE NOT FOUND</center>') else: self.browser.setSource(abspath(path)) def history_changed(self, row, col): logging.debug('history elem selected: %d:%d', row, col) index = (str(self.history.text(row, 0)), str(self.history.text(row, 1)), str(self.history.text(row, 2))) try: path = self.history_map[index] self.load_file(path) except KeyError, e: # can happen when qt sends us the signal with # null data and we get the key ("","","") pass
class ChangeSettingsUI(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) if not name: self.setName("Form1") Form1Layout = QVBoxLayout(self,11,6,"Form1Layout") self.splitter4 = QSplitter(self,"splitter4") self.splitter4.setOrientation(QSplitter.Horizontal) LayoutWidget = QWidget(self.splitter4,"layout29") layout29 = QGridLayout(LayoutWidget,1,1,11,6,"layout29") self.tblValues = QTable(LayoutWidget,"tblValues") self.tblValues.setResizePolicy(QTable.Default) self.tblValues.setNumRows(23) self.tblValues.setNumCols(7) self.tblValues.setSorting(0) layout29.addMultiCellWidget(self.tblValues,0,0,0,2) self.groupBox1 = QGroupBox(LayoutWidget,"groupBox1") self.groupBox1.setColumnLayout(0,Qt.Vertical) self.groupBox1.layout().setSpacing(6) self.groupBox1.layout().setMargin(11) groupBox1Layout = QGridLayout(self.groupBox1.layout()) groupBox1Layout.setAlignment(Qt.AlignTop) layout5 = QGridLayout(None,1,1,0,6,"layout5") self.spinAnalysis = QSpinBox(self.groupBox1,"spinAnalysis") layout5.addWidget(self.spinAnalysis,1,1) self.textLabel1_2 = QLabel(self.groupBox1,"textLabel1_2") layout5.addWidget(self.textLabel1_2,2,0) self.chkSimulatable = QCheckBox(self.groupBox1,"chkSimulatable") layout5.addWidget(self.chkSimulatable,0,0) self.textLabel1 = QLabel(self.groupBox1,"textLabel1") layout5.addWidget(self.textLabel1,1,0) self.spinEnv = QSpinBox(self.groupBox1,"spinEnv") layout5.addWidget(self.spinEnv,2,1) groupBox1Layout.addLayout(layout5,0,0) layout8 = QVBoxLayout(None,0,6,"layout8") layout7 = QHBoxLayout(None,0,6,"layout7") self.chkAnnBB = QCheckBox(self.groupBox1,"chkAnnBB") layout7.addWidget(self.chkAnnBB) self.chkAnnPoint = QCheckBox(self.groupBox1,"chkAnnPoint") layout7.addWidget(self.chkAnnPoint) layout8.addLayout(layout7) layout4 = QHBoxLayout(None,0,6,"layout4") self.textLabel2 = QLabel(self.groupBox1,"textLabel2") layout4.addWidget(self.textLabel2) self.txtFilename = QLineEdit(self.groupBox1,"txtFilename") self.txtFilename.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed,0,0,self.txtFilename.sizePolicy().hasHeightForWidth())) layout4.addWidget(self.txtFilename) self.btnOpenFile = QPushButton(self.groupBox1,"btnOpenFile") self.btnOpenFile.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Fixed,0,0,self.btnOpenFile.sizePolicy().hasHeightForWidth())) self.btnOpenFile.setMaximumSize(QSize(30,32767)) layout4.addWidget(self.btnOpenFile) layout8.addLayout(layout4) self.btnNetlist = QPushButton(self.groupBox1,"btnNetlist") layout8.addWidget(self.btnNetlist) groupBox1Layout.addLayout(layout8,0,1) layout29.addMultiCellWidget(self.groupBox1,2,2,0,2) self.btnSave = QPushButton(LayoutWidget,"btnSave") layout29.addWidget(self.btnSave,1,1) self.btnUpdate = QPushButton(LayoutWidget,"btnUpdate") layout29.addWidget(self.btnUpdate,1,0) self.btnPrint = QPushButton(LayoutWidget,"btnPrint") layout29.addWidget(self.btnPrint,1,2) self.tabWidget4 = QTabWidget(self.splitter4,"tabWidget4") self.tab = QWidget(self.tabWidget4,"tab") tabLayout = QVBoxLayout(self.tab,11,6,"tabLayout") self.txtNetlist = QTextEdit(self.tab,"txtNetlist") self.txtNetlist.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Expanding,0,0,self.txtNetlist.sizePolicy().hasHeightForWidth())) self.txtNetlist.setWordWrap(QTextEdit.NoWrap) self.txtNetlist.setWrapPolicy(QTextEdit.AtWordBoundary) tabLayout.addWidget(self.txtNetlist) self.tabWidget4.insertTab(self.tab,QString.fromLatin1("")) Form1Layout.addWidget(self.splitter4) self.languageChange() self.resize(QSize(854,621).expandedTo(self.minimumSizeHint())) self.clearWState(Qt.WState_Polished) def languageChange(self): self.setCaption(self.__tr("Form1")) self.groupBox1.setTitle(self.__tr("Netlist")) self.textLabel1_2.setText(self.__tr("Env point:")) self.chkSimulatable.setText(self.__tr("Simulatable")) self.textLabel1.setText(self.__tr("Analysis:")) self.chkAnnBB.setText(self.__tr("Annotate BB")) self.chkAnnPoint.setText(self.__tr("Annotate Point")) self.textLabel2.setText(self.__tr("Filename:")) self.btnOpenFile.setText(self.__tr("...")) self.btnNetlist.setText(self.__tr("Netlist")) self.btnSave.setText(self.__tr("save")) self.btnUpdate.setText(self.__tr("update")) self.btnPrint.setText(self.__tr("print")) self.tabWidget4.changeTab(self.tab,self.__tr("Netlist")) def __tr(self,s,c = None): return qApp.translate("ChangeSettingsUI",s,c)