Ejemplo n.º 1
0
    def showSettingsDialog(self):
        if self.settingsDialog:
            return

        self.settingsDialog = SettingsDialog()
        self.settingsDialog.finished.connect(self.onSettingsDialogFinished)
        self.settingsDialog.show()
Ejemplo n.º 2
0
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.trayIconMenu = QtWidgets.QMenu(self)
        self.settingsDialog = None

        self.addTrayAction()
        self.addTrayIcon()

    def addTrayAction(self):
        self.startAction = QtWidgets.QAction("Run",
                                             self,
                                             triggered=self.runKiller)
        self.stopAction = QtWidgets.QAction("Stop",
                                            self,
                                            triggered=self.stopKiller)
        self.settingAction = QtWidgets.QAction(
            "Settings", self, triggered=self.showSettingsDialog)
        self.quitAction = QtWidgets.QAction(
            "Quit", self, triggered=QtWidgets.QApplication.instance().quit)

    def refreshTrayMenu(self):
        self.trayIconMenu.clear()

        if common.isRunning():
            self.trayIconMenu.addAction(self.stopAction)
        else:
            self.trayIconMenu.addAction(self.startAction)
        self.trayIconMenu.addAction(self.settingAction)
        self.trayIconMenu.addSeparator()
        self.trayIconMenu.addAction(self.quitAction)

    def addTrayIcon(self):
        self.trayIcon = QtWidgets.QSystemTrayIcon(self)
        self.trayIcon.setContextMenu(self.trayIconMenu)
        self.trayIcon.setIcon(common.getIcon())
        self.trayIcon.show()

    def runKiller(self):
        common.run()
        self.refreshTrayMenu()

    def stopKiller(self):
        common.stop()
        self.refreshTrayMenu()

    def showSettingsDialog(self):
        if self.settingsDialog:
            return

        self.settingsDialog = SettingsDialog()
        self.settingsDialog.finished.connect(self.onSettingsDialogFinished)
        self.settingsDialog.show()

    def onSettingsDialogFinished(self, result):
        self.settingsDialog = None

    def onRunningStateChanged(self):
        self.refreshTrayMenu()
Ejemplo n.º 3
0
    def on_btnSettings_clicked(self):
        settingsDialog = SettingsDialog(kate.activeDocument().url(), self)
        settingsDialog.txtIncludePatterns.setPlainText("\n".join([r.pattern for r in self.lister.includeFilters]))
        settingsDialog.txtExcludePatterns.setPlainText("\n".join([r.pattern for r in self.lister.excludeFilters]))
        for path in self.projectPaths:
            settingsDialog.listProjectPaths.addItem(path)

        if settingsDialog.exec_():
            configPaths = self.config.group("ProjectPaths")
            for key in configPaths.keyList():
                configPaths.deleteEntry(key)
            self.projectPaths = []
            i = 0
            while i < settingsDialog.listProjectPaths.count():
                item = settingsDialog.listProjectPaths.item(i)
                configPaths.writePathEntry("path%s" % i, item.text())
                self.projectPaths.append(item.text())
                i += 1

            configFilters = self.config.group("Filters")
            includeFilters = settingsDialog.txtIncludePatterns.toPlainText()
            self.lister.setIncludeFilters(includeFilters)
            configFilters.writeEntry("include", includeFilters)

            excludeFilters = settingsDialog.txtExcludePatterns.toPlainText()
            self.lister.setExcludeFilters(excludeFilters)
            configFilters.writeEntry("exclude", excludeFilters)

            self.config.sync()
Ejemplo n.º 4
0
 def show_settings_dialog(self):
     dialog = SettingsDialog()
     dialog.source = self.source
     dialog.dest = self.dest
     if dialog.exec_():
         self.source = dialog.source
         self.dest = dialog.dest
Ejemplo n.º 5
0
Archivo: main.py Proyecto: CBo60Da/html
    def showConfigurationInterface(self):
        """Show settings dialog"""

        self.settings_dialog = SettingsDialog(self)

        dialog = KPageDialog()
        dialog.setFaceType(KPageDialog.Plain)
        dialog.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel))
        page = dialog.addPage(self.settings_dialog, "Settings")

        self.connect(dialog, SIGNAL("okClicked()"), self.configAccepted)
        self.connect(dialog, SIGNAL("cancelClicked()"), self.configDenied)

        dialog.resize(350, 200)
        dialog.exec_()
Ejemplo n.º 6
0
    def make_user_choose_paths(self) -> bool:  # return False if user cancelled
        xml_path = try_select_xml()
        if not xml_path:
            text = "You need to provide your Etterna.xml!"
            QMessageBox.critical(None, text, text)
            return False
        self._prefs.xml_path = xml_path

        replays_dir = os.path.abspath(
            os.path.join(os.path.dirname(xml_path), "../../ReplaysV2"))
        if os.path.exists(replays_dir):
            self._prefs.replays_dir = replays_dir

        songs_root = os.path.abspath(
            os.path.join(os.path.dirname(xml_path), "../../../Songs"))
        if os.path.exists(songs_root):
            self._prefs.songs_root = songs_root

        if self._prefs.replays_dir is None or self._prefs.songs_root is None:
            QMessageBox.information(
                None, "Couldn't locate game data",
                "The ReplaysV2 directory and/or root songs directory could not be found. "
                + "Please select it manually in the following dialog")
            SettingsDialog().exec_()

        return True
Ejemplo n.º 7
0
 def __init__(self):
     QMainWindow.__init__(self)
     Ui_Main.__init__(self)
     self.setupUi(self)
     self.get_saved_ingredients()
     self.update_drink_list()
     self.serial = QtSerialPort.QSerialPort('/dev/ttyACM0',
                                            readyRead=self.receive)
     self.serial.open(QtCore.QIODevice.OpenModeFlag.ReadWrite)
     if not self.serial.isOpen():
         print("Initializing without Serial.")
     self.loadingDialog = LoadingDialog(self)
     self.passwordDialog = PasswordDialog(self)
     self.settingsDialog = SettingsDialog(self)
     self.init_animations()
     self.setWindowTitle("Choisissez une boisson!")
     self.settings.clicked.connect(self.open_password)
Ejemplo n.º 8
0
    def __init__(self):
        # Construct app, root widget and layout
        self.qapp = QApplication(["Kangalioo's Etterna stats analyzer"])

        # Prepare area for the widgets
        window = QMainWindow()
        root = QWidget()
        layout = QVBoxLayout(root)

        # setup style
        root.setStyleSheet(f"""
			background-color: {util.bg_color()};
			color: {util.text_color()};
		""")
        pg.setConfigOption("background", util.bg_color())
        pg.setConfigOption("foreground", util.text_color())

        main_menu = window.menuBar().addMenu("File")
        main_menu.addAction("Settings").triggered.connect(
            lambda: SettingsDialog().exec_())
        main_menu.addAction("About").triggered.connect(
            lambda: QMessageBox.about(None, "About", ABOUT_TEXT))

        # Put the widgets in
        self.setup_widgets(layout, window)

        # QScrollArea wrapper with scroll wheel scrolling disabled on plots. I did this to prevent
        # simultaneous scrolling and panning when hovering a plot while scrolling
        class ScrollArea(QScrollArea):
            def eventFilter(self, _obj, event) -> bool:
                if event.type() == QEvent.Wheel and any(
                        w.underMouse() for w in app.app.get_pg_plots()):
                    return True
                return False

        scroll = ScrollArea(window)
        scroll.setWidget(root)
        scroll.setWidgetResizable(True)
        window.setCentralWidget(scroll)

        # Start
        w, h = 1600, 3100
        if app.app.prefs.enable_all_plots: h += 1300  # More plots -> more room
        # ~ root.setMinimumSize(1000, h)
        root.setMinimumHeight(h)
        window.resize(w, h)
        window.show()
        util.keep(window)
Ejemplo n.º 9
0
 def __init__(self):
     super().__init__()
     # UI
     self.ui = uic.loadUi("nobs_ui.ui", self)
     self.ui.setWindowTitle("NOBS Player")
     self.settings_dialog = SettingsDialog(self)
     self.settings = self.settings_dialog.settings
     # Variables
     self.sort_ascending = False
     # Library object
     self.lib = LibGrabber()
     self.lib.load_lib()
     # Player object
     self.player = QMediaPlayer()
     self.main_playlist = QMediaPlaylist()
     # Setup
     self.connect_slots()
     self.populate_podcast_list()
     self.view_all_episodes()
     # Go!
     self.show()
    def setupUi(self):
        self.resize(QSize(826, 330))
        self.setWindowTitle("PyQt5: Multithreading Example")
        self.centralwidget = QWidget(self)

        self.gridLayout1 = QGridLayout(self.centralwidget)
        self.gridLayout1.setContentsMargins(0, 0, 0, 0)

        self.scrollArea = QScrollArea(self.centralwidget)
        self.scrollArea.setWidgetResizable(True)
        self.scrollAreaWidget = QWidget()
        self.scrollAreaWidget.setGeometry(0, 0, 1000, 1000)

        self.gridLayout2 = QFormLayout(self.scrollAreaWidget)
        self.scrollArea.setWidget(self.scrollAreaWidget)

        self.frame = QFrame(self.scrollAreaWidget)

        self.gridLayout = QGridLayout(self.frame)
        self.gridLayout.setContentsMargins(-1, -1, 320, -1)
        self.gridLayout.setSizeConstraint(QLayout.SetFixedSize)

        self.gridLayout2.addWidget(self.frame)

        self.normal_palette = QPalette()
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        self.normal_palette.setBrush(QPalette.Active, QPalette.WindowText,
                                     brush)
        brush = QBrush(QColor(0, 0, 0))
        brush.setStyle(Qt.SolidPattern)
        self.normal_palette.setBrush(QPalette.Inactive, QPalette.WindowText,
                                     brush)
        brush = QBrush(QColor(120, 120, 120))
        brush.setStyle(Qt.SolidPattern)
        self.normal_palette.setBrush(QPalette.Disabled, QPalette.WindowText,
                                     brush)

        self.green_palette = QPalette()
        brush = QBrush(QColor(19, 138, 15))
        brush.setStyle(Qt.SolidPattern)
        self.green_palette.setBrush(QPalette.Active, QPalette.WindowText,
                                    brush)
        brush = QBrush(QColor(19, 138, 15))
        brush.setStyle(Qt.SolidPattern)
        self.green_palette.setBrush(QPalette.Inactive, QPalette.WindowText,
                                    brush)
        brush = QBrush(QColor(120, 120, 120))
        brush.setStyle(Qt.SolidPattern)
        self.green_palette.setBrush(QPalette.Disabled, QPalette.WindowText,
                                    brush)

        self.red_palette = QPalette()
        brush = QBrush(QColor(200, 0, 26))
        brush.setStyle(Qt.SolidPattern)
        self.red_palette.setBrush(QPalette.Active, QPalette.WindowText, brush)
        brush = QBrush(QColor(200, 0, 26))
        brush.setStyle(Qt.SolidPattern)
        self.red_palette.setBrush(QPalette.Inactive, QPalette.WindowText,
                                  brush)
        brush = QBrush(QColor(120, 120, 120))
        brush.setStyle(Qt.SolidPattern)
        self.red_palette.setBrush(QPalette.Disabled, QPalette.WindowText,
                                  brush)

        self.setCounters(10)

        self.gridLayout1.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralwidget)

        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QRect(0, 0, 491, 21))

        self.editMenu = QMenu(self.menubar)
        self.editMenu.setTitle("Edit")

        self.config = QAction(self)
        self.config.setText("Configure")
        self.config.triggered.connect(lambda: SettingsDialog(self))

        self.startAll = QAction(self)
        self.startAll.setText("Start All")
        self.startAll.triggered.connect(self.startAllCounters)
        self.startAll.setShortcut("Ctrl+S")

        self.stopAll = QAction(self)
        self.stopAll.setText("Stop All")
        self.stopAll.triggered.connect(self.stopAllCounters)
        self.stopAll.setShortcut("Ctrl+T")

        self.resetAll = QAction(self)
        self.resetAll.setText("Reset All")
        self.resetAll.triggered.connect(self.resetAllCounters)
        self.resetAll.setShortcut("Ctrl+R")

        self.setMenuBar(self.menubar)

        self.editMenu.addAction(self.config)
        self.editMenu.addSeparator()
        self.editMenu.addAction(self.startAll)
        self.editMenu.addAction(self.stopAll)
        self.editMenu.addAction(self.resetAll)

        self.menubar.addAction(self.editMenu.menuAction())

        self.statusbar = QStatusBar(self)

        self.setStatusBar(self.statusbar)
        QMetaObject.connectSlotsByName(self)
Ejemplo n.º 11
0
class MainWindow(QMainWindow, Ui_Main):
    def __init__(self):
        QMainWindow.__init__(self)
        Ui_Main.__init__(self)
        self.setupUi(self)
        self.get_saved_ingredients()
        self.update_drink_list()
        self.serial = QtSerialPort.QSerialPort('/dev/ttyACM0',
                                               readyRead=self.receive)
        self.serial.open(QtCore.QIODevice.OpenModeFlag.ReadWrite)
        if not self.serial.isOpen():
            print("Initializing without Serial.")
        self.loadingDialog = LoadingDialog(self)
        self.passwordDialog = PasswordDialog(self)
        self.settingsDialog = SettingsDialog(self)
        self.init_animations()
        self.setWindowTitle("Choisissez une boisson!")
        self.settings.clicked.connect(self.open_password)

    def receive(self):
        while self.serial.canReadLine():
            text = self.serial.readLine().data().decode('ascii').strip('\r\n')
            if text == "Gobelet OK":
                pump = self.get_pump()
                # self.gif_gobelet.stop()
                self.gif_conveyor.start()
                self.loadingDialog.step.setText(
                    f"Moving carpet to position {pump}")
                self.serial.write(f"C{pump};".encode())
            elif text == "Carpet OK":
                pump = self.get_pump()
                self.gif_conveyor.stop()
                self.gif_glass.start()
                self.loadingDialog.step.setText(f"Pumping at position {pump}")
                self.serial.write(
                    f"P{pump}-{list(self.ing_dict.values())[0]};".encode())
                self.ing_dict.pop(list(self.ing_dict.keys())[0])
            elif text == "Pump OK":
                self.gif_glass.stop()
                self.gif_conveyor.start()
                if len(self.ing_dict) != 0:
                    pump = self.get_pump()
                    self.loadingDialog.step.setText(
                        f"Moving carpet to position {pump}")
                    self.serial.write(f"C{pump};".encode())
                else:
                    self.loadingDialog.step.setText("Moving carpet to the end")
                    self.serial.write("End;".encode())
            elif text == "End OK":
                self.gif_conveyor.stop()
                self.loadingDialog.finishedDialog.setModal(True)
                self.loadingDialog.finishedDialog.show()

    def get_pump(self):
        key = list(self.ing_dict.keys())[0]
        if key == self.settingsDialog.name1.text():
            pump = 1
        elif key == self.settingsDialog.name2.text():
            pump = 2
        elif key == self.settingsDialog.name3.text():
            pump = 3
        elif key == self.settingsDialog.name4.text():
            pump = 4
        elif key == self.settingsDialog.name5.text():
            pump = 5
        elif key == self.settingsDialog.name6.text():
            pump = 6
        return pump

    def update_drink_list(self):
        self.scrollContents = QtWidgets.QWidget()
        self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollContents)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setSpacing(20)
        self.create_cocktails()
        for i, cocktail in enumerate(self.current_cocktails):
            button = CustomButton(self, cocktail)
            sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)
            button.setSizePolicy(sizePolicy)
            button.setMinimumSize(QtCore.QSize(300, 200))
            self.gridLayout.addWidget(button, i // 3, i % 3)
        self.verticalLayout.addLayout(self.gridLayout)
        self.scrollArea.setWidget(self.scrollContents)

    def create_cocktails(self):
        self.current_cocktails = []
        for name, cocktail_info in cocktails.items():
            n = 0
            for ingredient in cocktail_info[0].keys():
                if ingredient in self.current_ingredients:
                    n += 1
            if n == len(cocktail_info[0]):
                self.current_cocktails.append(name)

    def get_saved_ingredients(self):
        try:
            with open('save.json', 'r') as file:
                self.current_ingredients = json.load(file)
        except FileNotFoundError:
            self.current_ingredients = ['', '', '', '', '', '']

    def set_saved_ingredients(self):
        self.current_ingredients = [
            self.settingsDialog.name1.text(),
            self.settingsDialog.name2.text(),
            self.settingsDialog.name3.text(),
            self.settingsDialog.name4.text(),
            self.settingsDialog.name5.text(),
            self.settingsDialog.name6.text()
        ]
        with open('save.json', 'w') as file:
            json.dump(self.current_ingredients, file)

    def open_password(self):
        self.passwordDialog.setModal(True)
        self.passwordDialog.show()

    def open_settings(self):
        self.settingsDialog.setModal(True)
        self.settingsDialog.show()

    def create_ing_dict(self, text):
        """Creates the dictionary of ingredients needed for the needed cocktail."""
        self.ing_dict = {}
        for key, value in cocktails.items():
            if key == text:
                self.ing_dict = copy.copy(value[0])
                break

    def init_animations(self):
        self.gif_conveyor = QtGui.QMovie(":/Logo/conveyor.gif")
        self.gif_conveyor.setScaledSize(QSize(512, 100))
        self.loadingDialog.conveyor.setMovie(self.gif_conveyor)
        self.gif_conveyor.start()
        self.gif_conveyor.stop()
        self.gif_glass = QtGui.QMovie(":/Logo/glass.gif")
        self.gif_glass.setScaledSize(QSize(100, 125))
        self.loadingDialog.glass.setMovie(self.gif_glass)
        self.gif_glass.start()
        self.gif_glass.stop()
Ejemplo n.º 12
0
 def openSettings(self):
     settings_dialog = SettingsDialog(self)
     settings_dialog.exec()
Ejemplo n.º 13
0
 def showOptions(self):
     s = SettingsDialog(self)
     s.show()
Ejemplo n.º 14
0
Archivo: main.py Proyecto: CBo60Da/html
class BWCBalancePlasmoid(plasmascript.Applet):
    def __init__(self, parent, args=None):
        plasmascript.Applet.__init__(self, parent)

    def init(self):
        """Applet settings"""

        self.setHasConfigurationInterface(True)
        self.resize(300, 300)
        self.setAspectRatioMode(1)

        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)

        self.step = 0
        self.wasWeekly = 0
        self.wasDaily = 0
        self.layout = QGraphicsGridLayout(self.applet)

        self.createOneDayLayout()

        self.setOneDayLayout()

        # SettingsDialog instance
        # see: settings.py
        self.settings_dialog = None

        # User credentials
        self.City = ''
        self.weekly = 1
        self.path = "/home/draed/wwidg/contents/images/"

        self.timer = QTimer()
        self.connect(self.timer, SIGNAL("timeout(bool)"), self.update)

        def postInit(self):
            self.timer.start(1000 * 60 * 60)
            self.update()

    def update(self):
        """Update label text"""
        pre = 'http://api.openweathermap.org/data/2.5/weather?q='
        if self.weekly:
            pre = 'http://api.openweathermap.org/data/2.5/forecast?q='
        post = '&appid=653ea39c344cd35c73b76e3766770422'
        if self.City != None:
            tar = str(self.City)
            request = pre + tar + post
            r = requests.get(request)
            self.data = r.json()

            if self.weekly:
                if self.wasDaily:
                    self.clear1()
                    self.wasDaily = 0
                self.createFiveDaysLayout()
                self.setWeekLayout()
                self.setFiveDaysData()
            else:
                if self.wasWeekly:
                    self.clear2()
                    self.wasWeekly = 0
                self.createOneDayLayout()
                self.setOneDayLayout()
                self.setOneDayData()

    def createOneDayLayout(self):

        self.layout.setColumnMaximumWidth(0, 300)
        self.wasDaily = 1
        self.clearLayout()
        self.resize(300, 300)

        self.nameLabel = Plasma.Label(self.applet)
        self.descLabel = Plasma.Label(self.applet)
        self.tempLabel = Plasma.Label(self.applet)
        self.humLabel = Plasma.Label(self.applet)
        self.layout.addItem(self.descLabel, 1, 0)
        self.layout.addItem(self.nameLabel, 0, 0)
        self.layout.addItem(self.tempLabel, 2, 0)
        self.layout.addItem(self.humLabel, 3, 0)

    def setOneDayData(self):
        self.nameLabel.setText(str(self.data['name']))
        self.descLabel.setText(str(self.data['weather'][0]['description']))
        self.tempLabel.setText(
            str(round(self.data['main']['temp'] - 273.15, 1)) + ' C')
        self.humLabel.setText(str(self.data['main']['humidity']) + '%')
        self.descLabel.setStyleSheet('font: 16pt "Monaco"')
        self.humLabel.setStyleSheet('font: 16pt "Monaco"')
        self.tempLabel.setStyleSheet('font: 16pt "Monaco"')
        self.nameLabel.setStyleSheet('font: 16pt "Monaco";')

    def createFiveDaysLayout(self):

        self.layout.setColumnMaximumWidth(0, 90)

        self.clearLayout()
        self.wasWeekly = 1

        self.resize(540, 300)
        """top"""
        self.dayLabels = []
        self.descLabels = []
        self.tempLabels = []
        self.timeBotLabels = []
        self.descBotLabels = []
        self.tempBotLabels = []
        self.humBotLabels = []
        for i in range(4):
            self.dayLabels.append(Plasma.Label(self.applet))
            self.descLabels.append(Plasma.Label(self.applet))
            self.tempLabels.append(Plasma.Label(self.applet))
            self.timeBotLabels.append(Plasma.Label(self.applet))
            self.descBotLabels.append(Plasma.Label(self.applet))
            self.tempBotLabels.append(Plasma.Label(self.applet))
            self.humBotLabels.append(Plasma.Label(self.applet))

        for i in range(4):
            self.layout.addItem(self.dayLabels[i], 0, i + 1)
            self.layout.addItem(self.descLabels[i], 1, i + 1)
            self.layout.addItem(self.tempLabels[i], 2, i + 1)
            self.layout.addItem(self.timeBotLabels[i], 3, i + 1)
            self.layout.addItem(self.descBotLabels[i], 4, i + 1)
            self.layout.addItem(self.tempBotLabels[i], 5, i + 1)
            self.layout.addItem(self.humBotLabels[i], 6, i + 1)

        self.tempLabelBot = Plasma.Label(self.applet)
        self.humLabelBot = Plasma.Label(self.applet)
        self.layout.addItem(self.tempLabelBot, 5, 0)
        self.layout.addItem(self.humLabelBot, 6, 0)
        self.tempLabelBot.setText("Temperature, C:")
        self.humLabelBot.setText("Humidity, %:")

        self.NameLabel = Plasma.Label(self.applet)
        self.DescLabel = Plasma.Label(self.applet)
        self.TempLabel = Plasma.Label(self.applet)
        self.layout.addItem(self.NameLabel, 0, 0)
        self.layout.addItem(self.DescLabel, 2, 0)
        self.layout.addItem(self.TempLabel, 1, 0)

        #btns
        self.rightButtn = Plasma.PushButton(self.applet)
        self.leftButton = Plasma.PushButton(self.applet)
        self.rightButtn.setText("Next")
        self.leftButton.setText("Prev")
        self.connect(self.rightButtn, SIGNAL("clicked()"), self.nextDay)
        self.connect(self.leftButton, SIGNAL("clicked()"), self.prevDay)
        self.layout.addItem(self.rightButtn, 0, 6)
        self.layout.addItem(self.leftButton, 6, 6)

    def setFiveDaysData(self):

        for i in range(4):
            stam = self.data['list'][0 + 8 * i]['dt']
            value = datetime.datetime.fromtimestamp(stam).strftime('%a')
            value2 = datetime.datetime.fromtimestamp(stam).strftime('%d %b')
            self.dayLabels[i].setText(value + '\n' + value2)
            self.descLabels[i].setImage(
                self.path +
                self.data['list'][0 + 8 * i]['weather'][0]['icon'] + ".png")
            min = str(
                round(
                    self.data['list'][0 + 8 * i]['main']['temp_min'] - 273.15,
                    1))
            max = str(
                round(
                    self.data['list'][0 + 8 * i]['main']['temp_max'] - 273.15,
                    1))
            self.tempLabels[i].setText("Min. " + "Max.\n" + min + "  " + max)

        # bot

        self.setBot()

        #left
        #self.NameLabel.setText(self.data['city']['name'])
        stam = self.data['list'][0]['dt']
        value = datetime.datetime.fromtimestamp(stam).strftime('%d')
        self.NameLabel.setText("Weather today,\n  " + value + ':00')
        self.DescLabel.setImage(self.path +
                                self.data['list'][0]['weather'][0]['icon'] +
                                ".png")
        self.TempLabel.setText(
            str(round(self.data['list'][0]['main']['temp'] - 273.15, 1)) + 'C')

        self.prevDay()

    def setBot(self):
        if self.step > 3:
            self.step -= 1
        if self.step < 0:
            self.step = 0

        for i in range(4):
            self.dayLabels[i].setStyleSheet("")
        self.dayLabels[self.step].setStyleSheet("color: red")

        for i in range(4):
            stam = self.data['list'][i * 2 + 8 * self.step]['dt']
            value = datetime.datetime.fromtimestamp(stam).strftime('%H' +
                                                                   ':00')
            self.timeBotLabels[i].setText(value)
            self.descBotLabels[i].setImage(self.path + self.data['list'][
                i * 2 + 8 * self.step]['weather'][0]['icon'] + ".png")
            temp = str(
                round(
                    self.data['list'][i * 2 + 8 * self.step]['main']['temp'] -
                    273.15, 1))
            self.tempBotLabels[i].setText(temp)
            self.humBotLabels[i].setText(
                str(self.data['list'][i * 2 +
                                      8 * self.step]['main']['humidity']) +
                "%")

    def clearLayout(self):
        while self.layout.count():
            #self.layout.removeAt(0)
            self.layout.removeItem(self.layout.itemAt(0))

    def clearLayoutt(self, layout):
        while layout.count():
            child = layout.takeAt(0)
            if child.widget() is not None:
                child.widget().deleteLater()
            elif child.layout() is not None:
                self.clearLayoutt(child.layout())

    def clear2(self):

        for i in range(4):
            self.dayLabels[i].setText("")
            self.descLabels[i].setText("")
            self.descLabels[i] = 0
            self.tempLabels[i].setText("")
            self.timeBotLabels[i].setText("")
            self.tempBotLabels[i].setText("")
            self.descBotLabels[i] = 0
            self.humBotLabels[i].setText("")
            self.humLabelBot = 0
            self.tempLabelBot = 0
            self.NameLabel = 0
            self.DescLabel = 0
            self.TempLabel = 0

        self.rightButtn = None
        self.leftButton = None

    def clear1(self):
        self.nameLabel = None
        self.descLabel = None
        self.tempLabel = None
        self.humLabel = None

    def timerEvent(self, event):
        self.update()

    def prevDay(self):

        self.step -= 1

        self.setBot()

    def nextDay(self):
        self.step += 1

        self.setBot()

    def setWeekLayout(self):
        self.applet.setLayout(self.layout)

    def setOneDayLayout(self):
        self.applet.setLayout(self.layout)

    def showConfigurationInterface(self):
        """Show settings dialog"""

        self.settings_dialog = SettingsDialog(self)

        dialog = KPageDialog()
        dialog.setFaceType(KPageDialog.Plain)
        dialog.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel))
        page = dialog.addPage(self.settings_dialog, "Settings")

        self.connect(dialog, SIGNAL("okClicked()"), self.configAccepted)
        self.connect(dialog, SIGNAL("cancelClicked()"), self.configDenied)

        dialog.resize(350, 200)
        dialog.exec_()

    def configAccepted(self):
        self.City = self.settings_dialog.get_city()
        self.weekly = self.settings_dialog.get_weekly()
        self.update()

    def configDenied(self):
        """Do nothing"""

        pass
Ejemplo n.º 15
0
 def settings_clicked(self):
     sd = SettingsDialog(parent=self.parent(), error_message=self.message,\
                 models_manager=self.models_manager)
     if sd.exec_()==QDialog.Accepted:
         self.models_manager.load_from_server()
         self.accept()
Ejemplo n.º 16
0
 def show_settings(self):
     settingsDialog = SettingsDialog(self.settings_dict, self)
     settingsDialog.settings_accepted.connect(self.updateSettings)
     settingsDialog.show()
Ejemplo n.º 17
0
 def openSettings(self):
     settings_dialog = SettingsDialog(self)
     settings_dialog.show()