def __init__(self, icon, icon_raised=None, size=None, parent=None): self._icon = icons.get_icon(icon) if isinstance(icon, str) else icon self._icon_raised = (icons.get_icon(icon_raised) if isinstance( icon_raised, str) else icon_raised) super(OnOffToolButton, self).__init__(self._icon, parent) self.installEventFilter(self) if size is not None: self.setIconSize(icons.get_iconsize(size))
def __initGUI__(self): self.project_display = QPushButton() self.project_display.setFocusPolicy(Qt.NoFocus) self.project_display.setMinimumWidth(100) self.project_display.clicked.connect(self.select_project) ft = QApplication.instance().font() ft.setPointSize(ft.pointSize() - 1) self.project_display.setFont(ft) new_btn = QToolButtonSmall(icons.get_icon('new_project')) new_btn.setToolTip('Create a new project...') new_btn.clicked.connect(self.show_newproject_dialog) # ---- layout ---- layout = QGridLayout(self) layout.addWidget(QLabel('Project :'), 0, 1) layout.addWidget(self.project_display, 0, 2) layout.addWidget(new_btn, 0, 3) layout.setSpacing(3) layout.setContentsMargins(0, 0, 0, 5) # (L, T, R, B) layout.setColumnStretch(0, 500) layout.setRowMinimumHeight(0, 28)
def __init__(self, parent=None): super(NewProject, self).__init__(parent) self.setWindowFlags(Qt.Window) self.setModal(True) self.setWindowTitle('New Project') self.setWindowIcon(icons.get_icon('master')) self.__initUI__()
def __init__(self, parent=None, pytesting=False): super(AboutWhat, self).__init__(parent) self._pytesting = pytesting self.setWindowTitle('About %s' % __appname__) self.setWindowIcon(icons.get_icon('master')) self.setMinimumSize(800, 700) self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint) self.__initUI__()
def __init__(self, wldset=None, parent=None): super(BRFViewer, self).__init__(parent) self.__save_ddir = osp.dirname(__rootdir__) self.setWindowTitle('BRF Results Viewer') self.setWindowIcon(icons.get_icon('master')) self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint) self.__initGUI__() self.set_wldset(wldset)
def __init__(self, wxdset=None, parent=None): super(WXDataMergerWidget, self).__init__(parent) self.setModal(False) self.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint) self.setWindowTitle('Combine two weather datasets') self.setWindowIcon(icons.get_icon('master')) self._workdir = os.getcwd() self.__initUI__()
def __init__(self, parent=None, resizable=False, maximize=True): super(DialogWindow, self).__init__(parent) self.__firstshow = True if maximize is True: self.__resizable = True self.setWindowFlags(Qt.Window) else: self.__resizable = resizable self.setWindowFlags(Qt.Window | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint) self.setWindowIcon(icons.get_icon('master'))
def __init__(self, parent=None): super(TabWidget, self).__init__(parent=None) self._pytesting = False self.about_win = None self.about_btn = QToolButtonBase(icons.get_icon('info')) self.about_btn.setIconSize(icons.get_iconsize('small')) self.about_btn.setFixedSize(32, 32) self.about_btn.setToolTip('About GWHAT...') self.about_btn.setParent(self) self.about_btn.clicked.connect(self._about_btn_isclicked) tab_bar = TabBar(self, parent) self.setTabBar(tab_bar) tab_bar.sig_resized.connect(self.__move_about_btn) tab_bar.sig_tab_layout_changed.connect(self.__move_about_btn) self.about_btn.raise_()
def setup_toolbar(self): """Setup the toolbar of the widget. """ toolbar = QWidget() btn_calib = QPushButton('Compute Recharge') btn_calib.clicked.connect(self.btn_calibrate_isClicked) self.btn_show_result = QToolButtonSmall(icons.get_icon('search')) self.btn_show_result.clicked.connect(self.figstack.show) self.btn_show_result.setToolTip("Show GLUE results.") self.btn_save_glue = ExportGLUEButton(self.wxdset) layout = QGridLayout(toolbar) layout.addWidget(btn_calib, 0, 0) layout.addWidget(self.btn_show_result, 0, 1) layout.addWidget(self.btn_save_glue, 0, 2) layout.setContentsMargins(10, 0, 10, 0) # (L, T, R, B) return toolbar
def __init__(self, parent=None, pytesting=False): super(ManagerUpdates, self).__init__(parent) self._pytesting = pytesting self.setWindowTitle('GWHAT updates') self.setWindowIcon(icons.get_icon('master')) self.setMinimumSize(800, 700) self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint) self.setAttribute(Qt.WA_DeleteOnClose) self.setStandardButtons(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok) self.thread_updates = QThread() self.worker_updates = WorkerUpdates() self.worker_updates.moveToThread(self.thread_updates) self.thread_updates.started.connect(self.worker_updates.start) self.worker_updates.sig_ready.connect(self._receive_updates_check) self.start_updates_check()
def __init__(self, parent=None): super(PageSetupWin, self).__init__(parent) self.setWindowTitle('Page and Figure Setup') self.setWindowIcon(icons.get_icon('master')) self.setWindowFlags(Qt.Window | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint) # ---- Default Values ---- self.pageSize = (11, 7) self.isLegend = True self.isGraphTitle = True self.isTrendLine = False self.is_meteo_on = True self.is_glue_wl_on = False self.is_mrc_wl_on = False self.va_ratio = 0.2 self.figframe_lw = 0 self.__initUI__()
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle(__namever__) self.setWindowIcon(icons.get_icon('master')) if platform.system() == 'Windows': import ctypes myappid = 'gwhat_application' # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( myappid) # Setup preferences : self.whatPref = WHATPref(self) self.projectfile = self.whatPref.projectfile self.projectdir = osp.dirname(self.projectfile) # Setup the project and data managers : splash.showMessage("Initializing project and data managers...") self.pmanager = ProjetManager(self) self.pmanager.currentProjetChanged.connect(self.new_project_loaded) self.dmanager = DataManager(parent=self, pm=self.pmanager) self.dmanager.setMaximumWidth(250) # Generate the GUI : self.__initUI__() splash.finish(self) self.showMaximized() # Load the last opened project : result = self.pmanager.load_project(self.projectfile) if result is False: self.tab_dwnld_data.setEnabled(False) self.tab_fill_weather_data.setEnabled(False) self.tab_hydrograph.setEnabled(False) self.tab_hydrocalc.setEnabled(False)
def __initUI__(self): # ---- Toolbar self.btn_save = btn_save = QToolButtonNormal(icons.get_icon('save')) btn_save.setToolTip('Save the well hydrograph') # btn_draw is usefull for debugging purposes btn_draw = QToolButtonNormal(icons.get_icon('refresh')) btn_draw.setToolTip('Force a refresh of the well hydrograph') btn_draw.hide() self.btn_load_layout = QToolButtonNormal( icons.get_icon('load_graph_config')) self.btn_load_layout.setToolTip( "<p>Load graph layout for the current water level " " datafile if it exists</p>") self.btn_load_layout.clicked.connect(self.load_layout_isClicked) self.btn_save_layout = QToolButtonNormal( icons.get_icon('save_graph_config')) self.btn_save_layout.setToolTip('Save current graph layout') self.btn_save_layout.clicked.connect(self.save_layout_isClicked) btn_bestfit_waterlvl = QToolButtonNormal(icons.get_icon('fit_y')) btn_bestfit_waterlvl.setToolTip('Best fit the water level scale') btn_bestfit_time = QToolButtonNormal(icons.get_icon('fit_x')) btn_bestfit_time.setToolTip('Best fit the time scale') self.btn_page_setup = QToolButtonNormal(icons.get_icon('page_setup')) self.btn_page_setup.setToolTip('Show the page setup window') self.btn_page_setup.clicked.connect(self.page_setup_win.show) btn_color_pick = QToolButtonNormal(icons.get_icon('color_picker')) btn_color_pick.setToolTip('<p>Show a window to setup the color palette' ' used to draw the hydrograph</p.') btn_color_pick.clicked.connect(self.color_palette_win.show) self.btn_language = LangToolButton() self.btn_language.setToolTip( "Set the language of the text shown in the graph.") self.btn_language.sig_lang_changed.connect(self.layout_changed) self.btn_language.setIconSize(icons.get_iconsize('normal')) # ---- Zoom Panel btn_zoom_out = QToolButtonSmall(icons.get_icon('zoom_out')) btn_zoom_out.setToolTip('Zoom out (ctrl + mouse-wheel-down)') btn_zoom_out.clicked.connect(self.zoom_out) btn_zoom_in = QToolButtonSmall(icons.get_icon('zoom_in')) btn_zoom_in.setToolTip('Zoom in (ctrl + mouse-wheel-up)') btn_zoom_in.clicked.connect(self.zoom_in) self.zoom_disp = QSpinBox() self.zoom_disp.setAlignment(Qt.AlignCenter) self.zoom_disp.setButtonSymbols(QAbstractSpinBox.NoButtons) self.zoom_disp.setReadOnly(True) self.zoom_disp.setSuffix(' %') self.zoom_disp.setRange(0, 9999) self.zoom_disp.setValue(100) zoom_pan = myqt.QFrameLayout() zoom_pan.setSpacing(3) zoom_pan.addWidget(btn_zoom_out, 0, 0) zoom_pan.addWidget(btn_zoom_in, 0, 1) zoom_pan.addWidget(self.zoom_disp, 0, 2) # LAYOUT : btn_list = [ btn_save, btn_draw, self.btn_load_layout, self.btn_save_layout, VSep(), btn_bestfit_waterlvl, btn_bestfit_time, VSep(), self.btn_page_setup, btn_color_pick, self.btn_language, VSep(), zoom_pan ] subgrid_toolbar = QGridLayout() toolbar_widget = QWidget() row = 0 for col, btn in enumerate(btn_list): subgrid_toolbar.addWidget(btn, row, col) subgrid_toolbar.setSpacing(5) subgrid_toolbar.setContentsMargins(0, 0, 0, 0) subgrid_toolbar.setColumnStretch(col + 1, 100) toolbar_widget.setLayout(subgrid_toolbar) # ---- LEFT PANEL # SubGrid Hydrograph Frame : self.hydrograph = hydrograph.Hydrograph() self.hydrograph_scrollarea = mplFigViewer.ImageViewer() self.hydrograph_scrollarea.zoomChanged.connect(self.zoom_disp.setValue) grid_hydrograph = QGridLayout() grid_hydrograph.addWidget(self.hydrograph_scrollarea, 0, 0) grid_hydrograph.setRowStretch(0, 500) grid_hydrograph.setColumnStretch(0, 500) grid_hydrograph.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) # ASSEMBLING SubGrids : grid_layout = QGridLayout() self.grid_layout_widget = QFrame() row = 0 grid_layout.addWidget(toolbar_widget, row, 0) row += 1 grid_layout.addLayout(grid_hydrograph, row, 0) grid_layout.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) grid_layout.setSpacing(5) grid_layout.setColumnStretch(0, 500) grid_layout.setRowStretch(1, 500) self.grid_layout_widget.setLayout(grid_layout) # ---- Right Panel self.tabscales = self.__init_scalesTabWidget__() self.right_panel = myqt.QFrameLayout() self.right_panel.addWidget(self.dmngr, 0, 0) self.right_panel.addWidget(self.tabscales, 1, 0) self.right_panel.setRowStretch(2, 100) self.right_panel.setSpacing(15) # ---- MAIN GRID mainGrid = QGridLayout() mainGrid.addWidget(self.grid_layout_widget, 0, 0) mainGrid.addWidget(VSep(), 0, 1) mainGrid.addWidget(self.right_panel, 0, 2) mainGrid.setContentsMargins(10, 10, 10, 10) # (L, T, R, B) mainGrid.setSpacing(15) mainGrid.setColumnStretch(0, 500) mainGrid.setColumnMinimumWidth(2, 250) self.setLayout(mainGrid) # ---- EVENTS # Toolbox Layout : btn_bestfit_waterlvl.clicked.connect(self.best_fit_waterlvl) btn_bestfit_time.clicked.connect(self.best_fit_time) btn_draw.clicked.connect(self.draw_hydrograph) btn_save.clicked.connect(self.select_save_path) # Hydrograph Layout : self.Ptot_scale.valueChanged.connect(self.layout_changed) self.qweather_bin.currentIndexChanged.connect(self.layout_changed) # ---- Init Image self.hydrograph_scrollarea.load_mpl_figure(self.hydrograph)
def __initUI__(self): self.setWindowTitle('Weather Averages') self.setWindowIcon(icons.get_icon('master')) # ---- Toolbar # Initialize the widgets : menu_save = QMenu() menu_save.addAction('Save normals graph as...', self.save_graph) menu_save.addAction('Save normals table as...', self.save_normals) btn_save = QToolButtonNormal(icons.get_icon('save')) btn_save.setToolTip('Save normals') btn_save.setMenu(menu_save) btn_save.setPopupMode(QToolButton.InstantPopup) btn_save.setStyleSheet("QToolButton::menu-indicator {image: none;}") self.btn_export = ExportWeatherButton() self.btn_export.setIconSize(icons.get_iconsize('normal')) btn_showStats = QToolButtonNormal(icons.get_icon('showGrid')) btn_showStats.setToolTip( "Show the monthly weather normals data table.") btn_showStats.clicked.connect(self.show_monthly_grid) btn_language = LangToolButton() btn_language.setToolTip( "Set the language of the text shown in the graph.") btn_language.sig_lang_changed.connect(self.set_lang) btn_language.setIconSize(icons.get_iconsize('normal')) # Instantiate and define a layout for the year range widget : self.year_rng = RangeSpinBoxes(1000, 9999) self.year_rng.setRange(1800, datetime.now().year) self.year_rng.sig_range_changed.connect(self.update_normals) btn_expand = QToolButtonVRectSmall(icons.get_icon('expand_range_vert')) btn_expand.clicked.connect(self.expands_year_range) btn_expand.setToolTip("Set the maximal possible year range.") lay_expand = QGridLayout() lay_expand.addWidget(self.year_rng.spb_upper, 0, 0) lay_expand.addWidget(btn_expand, 0, 1) lay_expand.setContentsMargins(0, 0, 0, 0) lay_expand.setSpacing(1) qgrid = QHBoxLayout(self.year_rng) qgrid.setContentsMargins(0, 0, 0, 0) qgrid.addWidget(QLabel('Year Range :')) qgrid.addWidget(self.year_rng.spb_lower) qgrid.addWidget(QLabel('to')) qgrid.addLayout(lay_expand) # Generate the layout of the toolbar : toolbar_widget = ToolBarWidget() for btn in [ btn_save, self.btn_export, btn_showStats, btn_language, None, self.year_rng ]: toolbar_widget.addWidget(btn) # ---- Main Layout # Initialize the widgets : self.fig_weather_normals = FigWeatherNormals() self.grid_weather_normals = GridWeatherNormals() self.grid_weather_normals.hide() # Generate the layout : mainGrid = QGridLayout() row = 0 mainGrid.addWidget(toolbar_widget, row, 0) row += 1 mainGrid.addWidget(self.fig_weather_normals, row, 0) row += 1 mainGrid.addWidget(self.grid_weather_normals, row, 0) mainGrid.setContentsMargins(10, 10, 10, 10) # (L, T, R, B) mainGrid.setSpacing(10) mainGrid.setRowStretch(row, 500) mainGrid.setColumnStretch(0, 500) self.setLayout(mainGrid)
def __initUI__(self): self.setWindowTitle('Weather Stations Browser') self.setWindowIcon(icons.get_icon('master')) self.setWindowFlags(Qt.Window) now = datetime.now() # ---- Tab Widget Search # ---- Proximity filter groupbox label_Lat = QLabel('Latitude :') label_Lat2 = QLabel('North') self.lat_spinBox = QDoubleSpinBox() self.lat_spinBox.setAlignment(Qt.AlignCenter) self.lat_spinBox.setSingleStep(0.1) self.lat_spinBox.setValue(0) self.lat_spinBox.setMinimum(0) self.lat_spinBox.setMaximum(180) self.lat_spinBox.setSuffix(u' °') self.lat_spinBox.valueChanged.connect(self.proximity_grpbox_toggled) label_Lon = QLabel('Longitude :') label_Lon2 = QLabel('West') self.lon_spinBox = QDoubleSpinBox() self.lon_spinBox.setAlignment(Qt.AlignCenter) self.lon_spinBox.setSingleStep(0.1) self.lon_spinBox.setValue(0) self.lon_spinBox.setMinimum(0) self.lon_spinBox.setMaximum(180) self.lon_spinBox.setSuffix(u' °') self.lon_spinBox.valueChanged.connect(self.proximity_grpbox_toggled) self.radius_SpinBox = QComboBox() self.radius_SpinBox.addItems(['25 km', '50 km', '100 km', '200 km']) self.radius_SpinBox.currentIndexChanged.connect( self.search_filters_changed) prox_search_grid = QGridLayout() row = 0 prox_search_grid.addWidget(label_Lat, row, 1) prox_search_grid.addWidget(self.lat_spinBox, row, 2) prox_search_grid.addWidget(label_Lat2, row, 3) row += 1 prox_search_grid.addWidget(label_Lon, row, 1) prox_search_grid.addWidget(self.lon_spinBox, row, 2) prox_search_grid.addWidget(label_Lon2, row, 3) row += 1 prox_search_grid.addWidget(QLabel('Search Radius :'), row, 1) prox_search_grid.addWidget(self.radius_SpinBox, row, 2) prox_search_grid.setColumnStretch(0, 100) prox_search_grid.setColumnStretch(4, 100) prox_search_grid.setRowStretch(row + 1, 100) prox_search_grid.setHorizontalSpacing(20) prox_search_grid.setContentsMargins(10, 10, 10, 10) # (L, T, R, B) self.prox_grpbox = QGroupBox("Proximity filter :") self.prox_grpbox.setCheckable(True) self.prox_grpbox.setChecked(False) self.prox_grpbox.toggled.connect(self.proximity_grpbox_toggled) self.prox_grpbox.setLayout(prox_search_grid) # ---- Province filter prov_names = ['All'] prov_names.extend(self.PROV_NAME) self.prov_widg = QComboBox() self.prov_widg.addItems(prov_names) self.prov_widg.setCurrentIndex(0) self.prov_widg.currentIndexChanged.connect(self.search_filters_changed) layout = QGridLayout() layout.addWidget(self.prov_widg, 2, 1) layout.setColumnStretch(2, 100) layout.setVerticalSpacing(10) prov_grpbox = QGroupBox("Province filter :") prov_grpbox.setLayout(layout) # ---- Data availability filter # Number of years with data self.nbrYear = QSpinBox() self.nbrYear.setAlignment(Qt.AlignCenter) self.nbrYear.setSingleStep(1) self.nbrYear.setMinimum(0) self.nbrYear.setValue(3) self.nbrYear.valueChanged.connect(self.search_filters_changed) subgrid1 = QGridLayout() subgrid1.addWidget(self.nbrYear, 0, 0) subgrid1.addWidget(QLabel('years of data between'), 0, 1) subgrid1.setHorizontalSpacing(10) subgrid1.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) subgrid1.setColumnStretch(2, 100) # Year range self.minYear = QSpinBox() self.minYear.setAlignment(Qt.AlignCenter) self.minYear.setSingleStep(1) self.minYear.setMinimum(1840) self.minYear.setMaximum(now.year) self.minYear.setValue(1840) self.minYear.valueChanged.connect(self.minYear_changed) label_and = QLabel('and') label_and.setAlignment(Qt.AlignCenter) self.maxYear = QSpinBox() self.maxYear.setAlignment(Qt.AlignCenter) self.maxYear.setSingleStep(1) self.maxYear.setMinimum(1840) self.maxYear.setMaximum(now.year) self.maxYear.setValue(now.year) self.maxYear.valueChanged.connect(self.maxYear_changed) subgrid2 = QGridLayout() subgrid2.addWidget(self.minYear, 0, 0) subgrid2.addWidget(label_and, 0, 1) subgrid2.addWidget(self.maxYear, 0, 2) subgrid2.setHorizontalSpacing(10) subgrid2.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) subgrid2.setColumnStretch(4, 100) # Subgridgrid assembly grid = QGridLayout() grid.addWidget(QLabel('Search for stations with at least'), 0, 0) grid.addLayout(subgrid1, 1, 0) grid.addLayout(subgrid2, 2, 0) grid.setVerticalSpacing(5) grid.setRowStretch(0, 100) # grid.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) self.year_widg = QGroupBox("Data Availability filter :") self.year_widg.setLayout(grid) # ---- Toolbar self.btn_addSta = btn_addSta = QPushButton('Add') btn_addSta.setIcon(icons.get_icon('add2list')) btn_addSta.setIconSize(icons.get_iconsize('small')) btn_addSta.setToolTip('Add selected found weather stations to the ' 'current list of weather stations.') btn_addSta.clicked.connect(self.btn_addSta_isClicked) btn_save = QPushButton('Save') btn_save.setIcon(icons.get_icon('save')) btn_save.setIconSize(icons.get_iconsize('small')) btn_save.setToolTip('Save current found stations info in a csv file.') btn_save.clicked.connect(self.btn_save_isClicked) self.btn_fetch = btn_fetch = QPushButton('Fetch') btn_fetch.setIcon(icons.get_icon('refresh')) btn_fetch.setIconSize(icons.get_iconsize('small')) btn_fetch.setToolTip("Updates the climate station database by" " fetching it again from the ECCC ftp server.") btn_fetch.clicked.connect(self.btn_fetch_isClicked) toolbar_grid = QGridLayout() toolbar_widg = QWidget() for col, btn in enumerate([btn_addSta, btn_save, btn_fetch]): toolbar_grid.addWidget(btn, 0, col + 1) toolbar_grid.setColumnStretch(toolbar_grid.columnCount(), 100) toolbar_grid.setSpacing(5) toolbar_grid.setContentsMargins(0, 30, 0, 0) # (L, T, R, B) toolbar_widg.setLayout(toolbar_grid) # ---- Left Panel panel_title = QLabel('<b>Weather Station Search Criteria :</b>') left_panel = QFrame() left_panel_grid = QGridLayout() left_panel_grid.addWidget(panel_title, 0, 0) left_panel_grid.addWidget(self.prox_grpbox, 1, 0) left_panel_grid.addWidget(prov_grpbox, 2, 0) left_panel_grid.addWidget(self.year_widg, 3, 0) left_panel_grid.setRowStretch(4, 100) left_panel_grid.addWidget(toolbar_widg, 5, 0) left_panel_grid.setVerticalSpacing(20) left_panel_grid.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) left_panel.setLayout(left_panel_grid) # ----- Main grid # Widgets vLine1 = QFrame() vLine1.setFrameStyle(StyleDB().VLine) # Grid main_layout = QGridLayout(self) main_layout.addWidget(left_panel, 0, 0) main_layout.addWidget(vLine1, 0, 1) main_layout.addWidget(self.station_table, 0, 2) main_layout.addWidget(self.waitspinnerbar, 0, 2) main_layout.setContentsMargins(10, 10, 10, 10) # (L,T,R,B) main_layout.setRowStretch(0, 100) main_layout.setHorizontalSpacing(15) main_layout.setVerticalSpacing(5) main_layout.setColumnStretch(col, 100)
def __initUI__(self): # ---- Current Date ---- now = datetime.now() now = (now.day, now.month, now.year, now.hour, now.minute) # ----------------------------------------------------- PROJECT INFO -- # ---- Widgets ---- self.name = QLineEdit() self.author = QLineEdit() self.date = QLabel('%02d/%02d/%d %02d:%02d' % now) self.createdby = QLabel(__namever__) # ---- Layout ---- projet_info = QGridLayout() row = 0 projet_info.addWidget(QLabel('Project Title :'), row, 0) projet_info.addWidget(self.name, row, 1) row += 1 projet_info.addWidget(QLabel('Author :'), row, 0) projet_info.addWidget(self.author, row, 1) row += 1 projet_info.addWidget(QLabel('Created :'), row, 0) projet_info.addWidget(self.date, row, 1) row += 1 projet_info.addWidget(QLabel('Software :'), row, 0) projet_info.addWidget(self.createdby, row, 1) projet_info.setSpacing(10) projet_info.setColumnStretch(1, 100) projet_info.setColumnMinimumWidth(1, 250) projet_info.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) # --------------------------------------------- LOCATION COORDINATES -- locaCoord_title = QLabel('<b>Project Location Coordinates:</b>') locaCoord_title.setAlignment(Qt.AlignLeft) self.lat_spinbox = myqt.QDoubleSpinBox(0, 3, 0.1, ' °') self.lat_spinbox.setRange(0, 180) self.lon_spinbox = myqt.QDoubleSpinBox(0, 3, 0.1, ' °') self.lon_spinbox.setRange(0, 180) # ----- layout ---- loc_coord = QGridLayout() row = 0 loc_coord.addWidget(locaCoord_title, row, 0, 1, 11) row += 1 loc_coord.setColumnStretch(0, 100) loc_coord.addWidget(QLabel('Latitude :'), row, 1) loc_coord.addWidget(self.lat_spinbox, row, 2) loc_coord.addWidget(QLabel('North'), row, 3) loc_coord.setColumnStretch(4, 100) loc_coord.addWidget(VSep(), row, 5) loc_coord.setColumnStretch(6, 100) loc_coord.addWidget(QLabel('Longitude :'), row, 7) loc_coord.addWidget(self.lon_spinbox, row, 8) loc_coord.addWidget(QLabel('West'), row, 9) loc_coord.setColumnStretch(10, 100) loc_coord.setSpacing(10) loc_coord.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) # --------------------------------------------------------- Browse ---- # ---- widgets ---- save_in_folder = os.path.abspath(os.path.join('..', 'Projects')) directory_label = QLabel('Save in Folder:') self.directory = QLineEdit() self.directory.setReadOnly(True) self.directory.setText(save_in_folder) self.directory.setMinimumWidth(350) btn_browse = QToolButton() btn_browse.setAutoRaise(True) btn_browse.setIcon(icons.get_icon('openFolder')) btn_browse.setIconSize(icons.get_iconsize('small')) btn_browse.setToolTip('Browse...') btn_browse.setFocusPolicy(Qt.NoFocus) btn_browse.clicked.connect(self.browse_saveIn_folder) browse = QGridLayout() browse.addWidget(directory_label, 0, 0) browse.addWidget(self.directory, 0, 1) browse.addWidget(btn_browse, 0, 2) browse.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) browse.setColumnStretch(1, 100) browse.setSpacing(10) # ---------------------------------------------------------- Toolbar -- # ---- widgets ---- btn_save = QPushButton(' Save') btn_save.setMinimumWidth(100) btn_save.clicked.connect(self.save_project) btn_cancel = QPushButton(' Cancel') btn_cancel.setMinimumWidth(100) btn_cancel.clicked.connect(self.close) # ---- layout ---- toolbar = QGridLayout() toolbar.addWidget(btn_save, 0, 1) toolbar.addWidget(btn_cancel, 0, 2) toolbar.setSpacing(10) toolbar.setColumnStretch(0, 100) toolbar.setContentsMargins(0, 0, 0, 0) # (L, T, R, B) # ------------------------------------------------------------- MAIN -- main_layout = QGridLayout(self) main_layout.addLayout(projet_info, 0, 0) main_layout.addWidget(HSep(), 1, 0) main_layout.addLayout(loc_coord, 2, 0) main_layout.addWidget(HSep(), 3, 0) main_layout.addLayout(browse, 4, 0) main_layout.addLayout(toolbar, 5, 0) main_layout.setVerticalSpacing(25) main_layout.setContentsMargins(15, 15, 15, 15) # (L, T, R, B)
self.sig_value_changed.emit(self.value()) def _setup_icon(self): """Setup the icon of the button according to its auto raise state.""" if self._icon_raised is None: return icon = self._icon_raised if self.value() else self._icon self.setIcon(icon) # %% if __name__ == '__main__' if __name__ == '__main__': app = QApplication(sys.argv) drop_button = DropDownButton(icon=icons.get_icon('todate')) drop_button.addItems([str(i) for i in range(2017, 1899, -1)]) onoff_button = OnOffToolButton('play', 'stop') onoff_button.setIconSize(icons.get_iconsize('normal')) lang_button = LangToolButton() lang_button.setIconSize(icons.get_iconsize('normal')) toolbar = ToolBarWidget() toolbar.addWidget(onoff_button) toolbar.addWidget(drop_button) toolbar.addWidget(lang_button) toolbar.show() sys.exit(app.exec_())
def __initGUI__(self): # ---- Navigator self.btn_prev = QToolButtonNormal(icons.get_icon('go_previous')) self.btn_prev.clicked.connect(self.navigate_brf) self.btn_next = QToolButtonNormal(icons.get_icon('go_next')) self.btn_next.clicked.connect(self.navigate_brf) self.current_brf = QSpinBox() self.current_brf.setRange(0, 99) self.current_brf.setAlignment(Qt.AlignCenter) self.current_brf.setButtonSymbols(QAbstractSpinBox.NoButtons) self.current_brf.setCorrectionMode( QAbstractSpinBox.CorrectToNearestValue) self.current_brf.valueChanged.connect(self.navigate_brf) self.current_brf.setValue(0) self.total_brf = QLabel('/ 0') # ---- Language button self.btn_language = LangToolButton() self.btn_language.setToolTip( "Set the language of the text shown in the graph.") self.btn_language.sig_lang_changed.connect(self.plot_brf) self.btn_language.setIconSize(icons.get_iconsize('normal')) # ---- Toolbar # Generate the buttons : self.btn_del = QToolButtonNormal(icons.get_icon('clear_search')) self.btn_del.setToolTip('Delete current BRF results') self.btn_del.clicked.connect(self.del_brf) self.btn_save = btn_save = QToolButtonNormal(icons.get_icon('save')) btn_save.setToolTip('Save current BRF graph...') btn_save.clicked.connect(self.select_savefig_path) self.btn_setp = QToolButtonNormal(icons.get_icon('page_setup')) self.btn_setp.setToolTip('Show graph layout parameters...') self.btn_setp.clicked.connect(self.toggle_graphpannel) # Generate the layout : self.tbar = myqt.QFrameLayout() buttons = [ btn_save, self.btn_del, VSep(), self.btn_prev, self.current_brf, self.total_brf, self.btn_next, VSep(), self.btn_setp, self.btn_language ] for btn in buttons: if isinstance(btn, QLayout): self.tbar.addLayout(btn, 1, self.tbar.columnCount()) else: self.tbar.addWidget(btn, 1, self.tbar.columnCount()) row = self.tbar.columnCount() self.tbar.addWidget(HSep(), 0, 0, 1, row + 1) self.tbar.setColumnStretch(row, 100) self.tbar.setContentsMargins(10, 0, 10, 10) # (l, t, r, b) # ---- Graph Canvas self.fig_frame = QFrame() self.fig_frame.setFrameStyle(StyleDB().frame) self.fig_frame.setObjectName("figframe") self.fig_frame.setStyleSheet("#figframe {background-color:white;}") self.brf_canvas = FigureCanvasQTAgg(BRFFigure()) fflay = QGridLayout(self.fig_frame) fflay.setContentsMargins(0, 0, 0, 0) # (left, top, right, bottom) fflay.addWidget(self.tbar, 1, 0) fflay.addWidget(self.brf_canvas, 0, 0) # ---- Graph Options Panel self.graph_opt_panel = BRFOptionsPanel() self.graph_opt_panel.sig_graphconf_changed.connect(self.plot_brf) # ---- Main Layout ml = QGridLayout(self) ml.addWidget(self.fig_frame, 0, 2) ml.addWidget(self.graph_opt_panel, 0, 3) ml.setColumnStretch(1, 100)
def __initUI__(self): # ---- Toolbar ---- self.btn_saveas = QPushButton('Save As...') self.btn_saveas.clicked.connect(self.btn_saveas_isClicked) self.btn_saveas.setEnabled(False) btn_cancel = QPushButton('Close') btn_cancel.clicked.connect(self.close) toolbar = QGridLayout() toolbar.addWidget(self.btn_saveas, 0, 1) toolbar.addWidget(btn_cancel, 0, 2) toolbar.setColumnStretch(0, 100) toolbar.setContentsMargins(0, 25, 0, 0) # (L, T, R, B) # ---- Central Widget ---- self._file_path1 = QLineEdit() self._file_path1.setReadOnly(True) lbl_get_file1 = QLabel("Select a first weather data file :") self.btn_get_file1 = QToolButtonSmall(icons.get_icon('openFile')) self.btn_get_file1.file_path = self._file_path1 self.btn_get_file1.clicked.connect(self.set_first_filepath) self._file_path2 = QLineEdit() self._file_path2.setReadOnly(True) lbl_get_file2 = QLabel("Select a second weather data file :") self.btn_get_file2 = QToolButtonSmall(icons.get_icon('openFile')) self.btn_get_file2.file_path = self._file_path2 self.btn_get_file2.clicked.connect(self.set_second_filepath) self._del_input_files_ckbox = QCheckBox( "Delete both original input datafiles after merging.") self._del_input_files_ckbox.setCheckState(Qt.Unchecked) # ---- Setup Layout ---- # Place widgets for file #1. central_layout = QGridLayout() row = 0 central_layout.addWidget(lbl_get_file1, row, 0, 1, 2) row += 1 central_layout.addWidget(self._file_path1, row, 0) central_layout.addWidget(self.btn_get_file1, row, 1) row += 1 central_layout.setRowMinimumHeight(row, 15) row += 1 # Place widgets for file #2. central_layout.addWidget(lbl_get_file2, row, 0, 1, 2) row += 1 central_layout.addWidget(self._file_path2, row, 0) central_layout.addWidget(self.btn_get_file2, row, 1) row += 1 central_layout.setRowMinimumHeight(row, 15) row += 1 central_layout.setRowMinimumHeight(row, 15) row += 1 central_layout.addWidget(self._del_input_files_ckbox, row, 0, 1, 2) central_layout.setColumnStretch(1, 100) # ---- Self Layout ---- layout = QGridLayout(self) layout.addLayout(central_layout, 0, 0) layout.addLayout(toolbar, 1, 0)
def __initGUI__(self): self.setContentsMargins(10, 10, 10, 10) self._bplag = {} self._bplag['label'] = QLabel('BP Lags Nbr:') self._bplag['widget'] = myqt.QDoubleSpinBox(100, 0) self._bplag['widget'].setRange(1, 9999) self._bplag['widget'].setValue(300) self._bplag['widget'].setKeyboardTracking(True) self._etlag = {} self._etlag['label'] = QLabel('ET Lags Nbr:') self._etlag['widget'] = myqt.QDoubleSpinBox(300, 0) self._etlag['widget'].setRange(-1, 9999) self._etlag['widget'].setValue(300) self._etlag['widget'].setKeyboardTracking(True) # ---- BRF Data Range ---- self._datastart = QDateTimeEdit() self._datastart.setCalendarPopup(True) self._datastart.setDisplayFormat('dd/MM/yyyy') self._dataend = QDateTimeEdit() self._dataend.setCalendarPopup(True) self._dataend.setDisplayFormat('dd/MM/yyyy') self.btn_seldata = QToolButtonSmall(icons.get_icon('select_range')) self.btn_seldata.clicked.connect(self.get_datarange) # ---- Detrend and Correct Options ---- self._detrend = QCheckBox('Detrend') self._detrend.setCheckState(Qt.Checked) self._correct = QCheckBox('Correct WL') self._correct.setEnabled(False) # ---- Toolbar btn_comp = QPushButton('Compute BRF') btn_comp.clicked.connect(self.calc_brf) btn_comp.setFocusPolicy(Qt.NoFocus) self.btn_show = btn_show = QToolButtonSmall(icons.get_icon('search')) btn_show.clicked.connect(self.viewer.show) # Layout tbar = myqt.QFrameLayout() tbar.addWidget(btn_comp, 0, 0) tbar.addWidget(btn_show, 0, 1) tbar.setColumnStretch(0, 100) # ---- Main Layout row = 0 self.addWidget(self._bplag['label'], row, 0) self.addWidget(self._bplag['widget'], row, 1) row += 1 self.addWidget(self._etlag['label'], row, 0) self.addWidget(self._etlag['widget'], row, 1) row += 1 self.setRowMinimumHeight(row, 15) row += 1 self.addWidget(QLabel('BRF Start :'), row, 0) self.addWidget(self._datastart, row, 1) self.addWidget(self.btn_seldata, row, 2) row += 1 self.addWidget(QLabel('BRF End :'), row, 0) self.addWidget(self._dataend, row, 1) row += 1 self.setRowMinimumHeight(row, 15) row += 1 self.addWidget(self._detrend, row, 0, 1, 2) row += 1 self.addWidget(self._correct, row, 0, 1, 2) row += 1 self.setRowMinimumHeight(row, 5) self.setRowStretch(row, 100) row += 1 self.addWidget(tbar, row, 0, 1, 3) self.setColumnStretch(self.columnCount(), 100) # ---- Install Panel if not KGSBRFInstaller().kgsbrf_is_installed(): self.__install_kgs_brf_installer()