コード例 #1
0
    def __init__(self):

        buxpaper.Window.__init__(self)

        self.editing = False

        self.sleepButton.clicked.connect(self.setSleepImage)
        self.sleepButton.show()

        self.previousButton = buxpaper.Button(u"\u25c4")
        self.previousButton.clicked.connect(self.previousMonth)
        self.panel.addWidget(self.previousButton)

        self.nextButton = buxpaper.Button(u"\u25ba")
        self.nextButton.clicked.connect(self.nextMonth)
        self.panel.addWidget(self.nextButton)

        self.config = buxpaper.Config(
            os.path.join(CalendarDir, "calendar.json"))
        self.config.load()

        self.label_format = self.config.get("Label format", self.LabelFormat)
        self.current_label_colour = self.config.get("Current label colour",
                                                    self.CurrentLabelColour)
        self.appointment_label_colour = self.config.get(
            "Appointment label colour", self.AppointmentLabelColour)

        self.appointments = self.config.get("Appointments", {})

        # Use a stacked layout inside the main content widget.
        layout = QStackedLayout(self.contentWidget)
        layout.setContentsMargins(0, 0, 0, 0)
        self.createMonthPage()
        layout.addWidget(self.monthPage)
        self.createDayPage()
        layout.addWidget(self.dayPage)

        today = datetime.date.today()
        self.showMonth(today.year, today.month)
コード例 #2
0
    def __init__(self):
    
        buxpaper.Window.__init__(self)
        
        self.index = 0
        
        self.sleepButton.clicked.connect(self.setSleepImage)
        self.sleepButton.show()
        
        browserIcon = buxpaper.icon_from_commands(buxpaper.browser_icon,
            self.closeButton.sizeHint().width(), self.closeButton.sizeHint().height())
        
        # Add a button for accessing the image browser.
        self.browserButton = buxpaper.Button(browserIcon)
        self.browserButton.clicked.connect(self.showBrowser)
        self.panel.addWidget(self.browserButton)
        
        # Add a button for accessing the adjustment panel.
        self.adjustImageWindow = AdjustImageWindow()
        self.adjustImageWindow.increaseBrightness.connect(self.increaseBrightness)
        self.adjustImageWindow.decreaseBrightness.connect(self.decreaseBrightness)
        self.adjustImageWindow.increaseContrast.connect(self.increaseContrast)
        self.adjustImageWindow.decreaseContrast.connect(self.decreaseContrast)
        self.adjustImageWindow.saveSettings.connect(self.saveSettings)
        
        self.adjustImageButton = buxpaper.Button(u"A")
        self.adjustImageButton.clicked.connect(self.adjustImage)
        self.panel.addWidget(self.adjustImageButton)
        
        self.saveThumbnailButton = buxpaper.Button(u"T")
        self.saveThumbnailButton.clicked.connect(self.saveThumbnail)
        self.saveThumbnailButton.hide()
        self.panel.addWidget(self.saveThumbnailButton)
        
        # Add a zoom button to the panel.
        self.zoomOutButton = buxpaper.Button("-")
        self.zoomOutButton.clicked.connect(self.zoomOut)
        self.panel.addWidget(self.zoomOutButton)

        self.previousButton = buxpaper.Button(u"\u25c4")
        self.previousButton.clicked.connect(self.previousPage)
        self.panel.addWidget(self.previousButton)
        
        self.nextButton = buxpaper.Button(u"\u25ba")
        self.nextButton.clicked.connect(self.nextPage)
        self.panel.addWidget(self.nextButton)
        
        self.config = buxpaper.Config(buxpaper.settings + "-gallery")
        self.config.load()
        
        # Use a stacked layout inside the main content widget.
        layout = QStackedLayout(self.contentWidget)
        layout.setContentsMargins(0, 0, 0, 0)
        self.createBrowserPage()
        layout.addWidget(self.browserPage)
        self.createPreviewPage()
        layout.addWidget(self.previewPage)
        
        self.showBrowser()
コード例 #3
0
 def __init__(self):
 
     buxpaper.Window.__init__(self)
     
     self.config = buxpaper.Config(buxpaper.settings + "-launcher")
     self.config.load()
     
     self.this_appdir = os.path.abspath(os.path.split(__file__)[0])
     
     self.process = None
     self.processLabel = None
     
     # Hide the close button.
     self.closeButton.hide()
     
     # Add a power status indicator.
     self.statusWidget = StatusWidget()
     self.panel.insertWidget(0, self.statusWidget)
     
     # Add buttons to the panel.
     self.previousButton = buxpaper.Button(u"\u25c4")
     self.previousButton.clicked.connect(self.previousPage)
     self.panel.addWidget(self.previousButton)
     
     self.nextButton = buxpaper.Button(u"\u25ba")
     self.nextButton.clicked.connect(self.nextPage)
     self.panel.addWidget(self.nextButton)
     
     # Create widgets inside the content widget.
     self.pages = QStackedWidget()
     
     layout = QVBoxLayout(self.contentWidget)
     layout.addWidget(self.pages)
     
     self.loadApplicationDetails()
     self.statusWidget.updateStatus()
     self.updateButtons()
コード例 #4
0
    def __init__(self):

        buxpaper.Window.__init__(self)

        self.pages = buxpaper.PagedWidget()
        self.pages.previousButton.hide()
        self.pages.nextButton.hide()
        self.pages.padding = 12

        self.previousButton = buxpaper.Button(u"\u25c4")
        self.panel.addWidget(self.previousButton)

        self.nextButton = buxpaper.Button(u"\u25ba")
        self.panel.addWidget(self.nextButton)

        self.pages.previousButtonState.connect(self.previousButton.setEnabled)
        self.pages.nextButtonState.connect(self.nextButton.setEnabled)
        self.previousButton.clicked.connect(self.pages.previousPage)
        self.nextButton.clicked.connect(self.pages.nextPage)

        layout = QVBoxLayout(self.contentWidget)
        layout.addWidget(self.pages)

        self.loadImageDetails()
コード例 #5
0
 def __init__(self, font):
 
     QDialog.__init__(self)
     self.setWindowFlags(Qt.CustomizeWindowHint)
     
     layout = QHBoxLayout(self)
     layout.setContentsMargins(0, 0, 0, 0)
     
     for i in range(-4, 6, 2):
         f = QFont(font)
         f.setPointSize(font.pointSize() + i)
         button = buxpaper.Button("F")
         button.setFont(f)
         button.clicked.connect(self.chooseFont)
         layout.addWidget(button)
     
     self.maxButtonSize = button.sizeHint()
コード例 #6
0
    def __init__(self):

        buxpaper.Window.__init__(self)

        self.mandelbrotWidget = MandelbrotWidget()

        self.sleepButton.clicked.connect(self.setSleepImage)
        self.sleepButton.show()
        self.mandelbrotWidget.viewChanged.connect(self.sleepButton.setEnabled)

        # Add a zoom button to the panel.
        zoomOutButton = buxpaper.Button("-")
        zoomOutButton.clicked.connect(self.mandelbrotWidget.zoomOut)
        self.panel.addWidget(zoomOutButton)

        layout = QVBoxLayout(self.contentWidget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.mandelbrotWidget)
コード例 #7
0
 def __init__(self):
 
     buxpaper.Window.__init__(self)
     
     self.viewer = Viewer()
     self.viewer.pageShown.connect(self.updatePageButtons)
     
     self.documentList = DocumentChooser()
     self.documentList.chosen.connect(self.openDocument)
     
     # Add buttons to the panel.
     self.sleepButton.clicked.connect(self.setSleepImage)
     self.sleepButton.show()
     
     self.previousButton = buxpaper.Button(u"\u25c4")
     self.previousButton.clicked.connect(self.documentList.previousPage)
     self.documentList.previousButtonState.connect(self.previousButton.setEnabled)
     self.panel.addWidget(self.previousButton)
     
     self.nextButton = buxpaper.Button(u"\u25ba")
     self.nextButton.clicked.connect(self.documentList.nextPage)
     self.documentList.nextButtonState.connect(self.nextButton.setEnabled)
     self.panel.addWidget(self.nextButton)
     
     self.backButton = buxpaper.Button(u"\u00ab")
     self.backButton.clicked.connect(self.viewer.backMany)
     self.panel.addWidget(self.backButton)
     
     self.forwardButton = buxpaper.Button(u"\u00bb")
     self.forwardButton.clicked.connect(self.viewer.forwardMany)
     self.panel.addWidget(self.forwardButton)
     
     self.fontSizeButton = buxpaper.Button("F")
     self.fontSizeButton.clicked.connect(self.setFontSize)
     self.panel.addWidget(self.fontSizeButton)
     
     self.documentButton = buxpaper.Button("B")
     self.documentButton.clicked.connect(self.chooseDocument)
     self.panel.addWidget(self.documentButton)
     
     layout = QStackedLayout(self.contentWidget)
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self.viewer)
     layout.addWidget(self.documentList)
     
     self.documentList.loadDocumentDetails()
コード例 #8
0
    def __init__(self):
    
        QWidget.__init__(self)
        self.setWindowFlags(Qt.CustomizeWindowHint)
        
        layout = QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        
        self.decreaseBrightnessButton = buxpaper.Button("-")
        self.increaseBrightnessButton = buxpaper.Button("+")
        self.decreaseBrightnessButton.clicked.connect(self.decreaseBrightness)
        self.increaseBrightnessButton.clicked.connect(self.increaseBrightness)

        brightnessIcon = buxpaper.icon_from_commands(brightness_icon,
            self.increaseBrightnessButton.sizeHint().width(),
            self.increaseBrightnessButton.sizeHint().height())
        
        label = buxpaper.Button(brightnessIcon)
        layout.addWidget(label, 0, 0)
        layout.addWidget(self.decreaseBrightnessButton, 0, 1)
        layout.addWidget(self.increaseBrightnessButton, 0, 2)
        
        self.decreaseContrastButton = buxpaper.Button("-")
        self.increaseContrastButton = buxpaper.Button("+")
        self.decreaseContrastButton.clicked.connect(self.decreaseContrast)
        self.increaseContrastButton.clicked.connect(self.increaseContrast)
        
        contrastIcon = buxpaper.icon_from_commands(contrast_icon,
            self.increaseContrastButton.sizeHint().width(),
            self.increaseContrastButton.sizeHint().height())
        
        label = buxpaper.Button(contrastIcon)
        layout.addWidget(label, 1, 0)
        layout.addWidget(self.decreaseContrastButton, 1, 1)
        layout.addWidget(self.increaseContrastButton, 1, 2)
        
        self.saveButton = buxpaper.Button(u"\u2713")
        self.saveButton.clicked.connect(self.saveSettings)
        layout.addWidget(self.saveButton, 0, 3, 2, 1)
コード例 #9
0
 def loadApplicationDetails(self):
 
     # Obtain a list of applications to exclude.
     exclude = self.config.get("Exclude applications", [])
     
     rows = self.config.get("Rows", 2)
     columns = self.config.get("Columns", 3)
     width = self.config.get("Thumbnail width", buxpaper.thumbnail_size[0])
     height = self.config.get("Thumbnail height", buxpaper.thumbnail_size[1])
     spacing = self.config.get("Thumbnail spacing", 12)
     row = column = 0
     
     for name in os.listdir(buxpaper.appdir):
     
         if name in exclude:
             continue
         
         # Construct the full application directory for this entry.
         appdir = os.path.abspath(os.path.join(buxpaper.appdir, name))
         
         # Don't include the launcher itself in the collection.
         if appdir == self.this_appdir:
             continue
         
         if not os.path.isdir(appdir):
             continue
         
         # Create a new widget if we are starting a new page.
         if row == 0 and column == 0:
             page = QWidget()
             pageLayout = QGridLayout(page)
             pageLayout.setSpacing(spacing)
             pageLayout.setMargin(spacing)
         
         container = QWidget()
         layout = QVBoxLayout(container)
         layout.setAlignment(Qt.AlignHCenter)
         layout.setMargin(0)
         
         icon_file = os.path.join(appdir, name.lower() + ".png")
         if os.path.isfile(icon_file):
         
             image = QImage(icon_file)
             image = image.scaled(width, height, Qt.KeepAspectRatio,
                                  Qt.SmoothTransformation)
             
             button = buxpaper.Button(image)
             button.data = appdir
             button.clicked.connect(self.runApplication)
             layout.addWidget(button)
             # Apparently necessary to update the layout...
             layout.setAlignment(button, Qt.AlignHCenter)
         
         label = buxpaper.Label(name, appdir)
         label.setAlignment(Qt.AlignHCenter)
         label.setFrameShape(QFrame.NoFrame)
         label.clicked.connect(self.runApplication)
         layout.addWidget(label)
         # Apparently necessary to update the layout...
         layout.setAlignment(label, Qt.AlignHCenter)
         
         pageLayout.addWidget(container, row, column)
         
         # Move to the next space in the page.
         column = (column + 1) % columns
         if column == 0:
             row = (row + 1) % rows
             if row == 0:
                 # If we need to start a new page then insert the current
                 # page into the stack.
                 page.adjustSize()
                 self.pages.addWidget(page)
     
     # Insert any unfinished page into the stack.
     if row != 0 or column != 0:
         page.adjustSize()
         self.pages.addWidget(page)
     
     self.pages.setCurrentIndex(0)
コード例 #10
0
    def __init__(self):

        buxpaper.Window.__init__(self)

        self.config = buxpaper.Config(buxpaper.settings + "-sketch")
        self.config.load()

        self.viewer = Viewer(self.config)
        self.currentTime = time.time()

        self.documentList = DocumentChooser(self.config)
        self.documentList.chosen.connect(self.openDocument)

        # Add buttons to the panel.
        self.sleepButton.clicked.connect(self.setSleepImage)
        self.sleepButton.show()

        browserIcon = buxpaper.icon_from_commands(
            buxpaper.browser_icon,
            self.closeButton.sizeHint().width(),
            self.closeButton.sizeHint().height())

        # Viewer buttons

        # Add a button for accessing the image browser.
        self.browserButton = buxpaper.Button(browserIcon)
        self.browserButton.clicked.connect(self.showBrowser)
        self.panel.addWidget(self.browserButton)

        self.annotateButton = buxpaper.Button(u"T")
        self.annotateButton.clicked.connect(self.annotateDocument)
        self.panel.addWidget(self.annotateButton)

        self.clearButton = buxpaper.Button(u"\u2718")
        self.clearButton.clicked.connect(self.clearDocument)
        self.panel.addWidget(self.clearButton)

        self.storeButton = buxpaper.Button(u"\u2714")
        self.storeButton.setEnabled(False)
        self.storeButton.clicked.connect(self.storeDocument)
        self.viewer.saved.connect(self.storeButton.setDisabled)
        self.panel.addWidget(self.storeButton)

        # Browser buttons

        # Add a button to allow creation of a new document.
        self.newButton = buxpaper.Button(u"+")
        self.newButton.clicked.connect(self.newDocument)
        self.panel.addWidget(self.newButton)

        # Add navigation buttons.
        self.previousButton = buxpaper.Button(u"\u25c4")
        self.previousButton.clicked.connect(self.previousPage)
        self.panel.addWidget(self.previousButton)
        self.documentList.hasPrevious.connect(self.previousButton.setEnabled)
        self.viewer.hasPrevious.connect(self.previousButton.setEnabled)
        self.viewer.changed.connect(self.sleepButton.setEnabled)
        self.viewer.changed.connect(self.storeButton.setEnabled)

        self.nextButton = buxpaper.Button(u"\u25ba")
        self.nextButton.clicked.connect(self.nextPage)
        self.panel.addWidget(self.nextButton)
        self.documentList.hasNext.connect(self.nextButton.setEnabled)
        self.viewer.hasNext.connect(self.nextButton.setEnabled)

        layout = QStackedLayout(self.contentWidget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.viewer)
        layout.addWidget(self.documentList)

        self.documentList.loadDocumentDetails()

        # Wait until the window has been given its final geometry before
        # attempting to lay out the browser.
        QTimer.singleShot(0, self.showBrowser)
コード例 #11
0
    def showPage(self):

        width = self.config.get("Thumbnail width", buxpaper.thumbnail_size[0])
        height = self.config.get("Thumbnail height",
                                 buxpaper.thumbnail_size[1])
        spacing = self.config.get("Thumbnail spacing", 12)
        row = column = 0
        this = self.index * self.rows * self.columns
        next = (self.index + 1) * self.rows * self.columns

        # Remove any existing child widgets.
        for child in self.children():
            child.deleteLater()

        # Use a single child widget that can be disposed of later.
        pageWidget = QWidget(self)
        pageWidget.setGeometry(0, 0, self.width(), self.height())
        pageLayout = QGridLayout(pageWidget)
        pageLayout.setMargin(spacing)
        pageLayout.setSpacing(spacing)

        for name in self.names[this:next]:

            container = QWidget(self)
            layout = QVBoxLayout(container)
            layout.setAlignment(Qt.AlignHCenter)
            layout.setMargin(0)

            drawing_path = os.path.join(buxpaper.drawdir, name)
            d = Document()
            if d.load(drawing_path):

                image = QImage(d.width, d.height, QImage.Format_RGB16)
                image.fill(Qt.white)
                p = QPainter()
                p.begin(image)
                d.paint(p)
                p.end()
                image = image.scaled(width, height, Qt.KeepAspectRatio,
                                     Qt.SmoothTransformation)
            else:
                image = QImage(width, height, QImage.Format_RGB16)
                image.fill(Qt.gray)

            button = buxpaper.Button(image)
            button.data = drawing_path
            button.clicked.connect(self.chooseDocument)
            layout.addWidget(button)
            layout.setAlignment(button, Qt.AlignHCenter)

            label = buxpaper.Label(name, drawing_path)
            label.setAlignment(Qt.AlignHCenter)
            label.setWordWrap(True)
            label.setFrameShape(QFrame.NoFrame)
            label.clicked.connect(self.chooseDocument)
            layout.addWidget(label)
            layout.setAlignment(label, Qt.AlignHCenter)

            pageLayout.addWidget(container, row, column)

            column = (column + 1) % self.columns
            if column == 0:
                row = row + 1

        pageWidget.show()

        self.hasDocuments.emit(len(self.names) > 0)
        self.hasPrevious.emit(self.currentIndex() > 0)
        self.hasNext.emit(self.currentIndex() < self.count() - 1)