我想作一個基於oschina的跨平臺的筆記軟件(作得好就分享給你們,作的很差就本身收藏....,oschina openapi方面已經熟悉了一下,可是Qt還不是很熟悉,由於仍是學習中...),下面講我在用其餘的筆記軟件經常遇到如下幾個問題:python
爲知筆記
的確是個不錯的選擇桌面便籤
,日曆提醒
等一些人性化的功能,暫時以爲只有爲之筆記
的windows客戶端能獲得這個要求目標的基本功能大體:linux
<!-- lang: python --> # -*- coding:utf8 -*- from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * from PyQt4.QtGui import * import mainQss class mainUi(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) #self.shadow = QGraphicsDropShadowEffect(self) #self.shadow.setBlurRadius(15) #self.shadow.setColor(QColor("blue")) #self.shadow.setOffset(20, 20) #self.setGraphicsEffect(self.shadow) self.setWindowFlags(Qt.FramelessWindowHint) self.layout = QHBoxLayout(self) self.leftwidget = QWidget() self.centerwidget = QWidget() self.rightwidget = QWidget() self.leftwidget.setMaximumWidth(300) self.leftwidget.setMinimumWidth(200) self.leftwidget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) # growflag self.centerwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # growflag self.rightwidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) # growflag self.centerwidget.setMinimumWidth(550) self.rightwidget.setMinimumWidth(250) self.rightwidget.setMaximumWidth(300) self.leftwidget.setStyleSheet(mainQss.threeWidget) self.centerwidget.setStyleSheet(mainQss.threeWidget) self.rightwidget.setStyleSheet(mainQss.threeWidget) headLabel = QLabel(self.rightwidget) headLabel.setStyleSheet(mainQss.headLabel) headLabel.setGeometry(25, 50, 80, 80) blogButton = QPushButton(u'個人博客',self.rightwidget) blogButton.setStyleSheet(mainQss.textButton) blogButton.setGeometry(25, 180, 150, 30) blogWriteButton = QPushButton(self.rightwidget) blogWriteButton.setStyleSheet(mainQss.writeButton) blogWriteButton.setGeometry(180, 182, 24, 24) noteButton = QPushButton(u'平常筆記',self.rightwidget) noteButton.setStyleSheet(mainQss.textButton) noteButton.setGeometry(25, 220, 150, 30) noteWriteButton = QPushButton(self.rightwidget) noteWriteButton.setStyleSheet(mainQss.writeButton) noteWriteButton.setGeometry(180, 222, 24, 24) taskButton = QPushButton(u'今日任務',self.rightwidget) taskButton.setStyleSheet(mainQss.textButton) taskButton.setGeometry(25, 260, 150, 30) taskWriteButton = QPushButton(self.rightwidget) taskWriteButton.setStyleSheet(mainQss.writeButton) taskWriteButton.setGeometry(180, 262, 24, 24) self.btnClose = QPushButton(self.leftwidget) self.btnMini = QPushButton(self.leftwidget) self.btnMax = QPushButton(self.leftwidget) self.btnClose.setGeometry(5, 5, 24, 24) self.btnMini.setGeometry(64, 5, 24, 24) self.btnMax.setGeometry(35, 5, 24, 24) self.btnClose.setStyleSheet(mainQss.btn_close) self.btnMini.setStyleSheet(mainQss.btn_mini) self.btnMax.setStyleSheet(mainQss.btn_max) self.leftLayout = QVBoxLayout() self.centerLayout = QVBoxLayout() self.rightLayout = QVBoxLayout() self.leftLayout.addWidget(self.leftwidget) self.centerLayout.addWidget(self.centerwidget) self.rightLayout.addWidget(self.rightwidget) self.layout.addLayout(self.leftLayout) self.layout.addLayout(self.centerLayout) self.layout.addLayout(self.rightLayout) self.maxToNor = False self.layout.setContentsMargins(0,0,0,0) self.layout.setSpacing(0) self.setLayout(self.layout) self.setWindowOpacity(0.95) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Ignored) self.resize(1000, 600) self.connect(self.btnClose, SIGNAL("clicked()"), QtGui.qApp, \ SLOT("quit()")) self.connect(self.btnMini, SIGNAL("clicked()"),self.showMinimized) self.connect(self.btnMax, SIGNAL("clicked()"),self.showMaxNor) def showMaxNor(self): if self.maxToNor: self.showNormal() self.maxToNor = False else: self.showMaximized() self.maxToNor = True def mousePressEvent(self, event): if self.isMaximized(): return if event.button() == Qt.LeftButton: self.dragPos = event.globalPos() - self.pos() event.accept() def mouseMoveEvent(self, QMouseEvent): if self.isMaximized(): return if QMouseEvent.buttons() and Qt.LeftButton: self.move(QMouseEvent.globalPos() - self.dragPos) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): pass if __name__ == "__main__": import sys app = QApplication(sys.argv) mu = mainUi()
<!-- lang: python --> # -*- coding:utf8 -*- btn_close = ''' QPushButton{ background-image: url(./img/close.png); border-radius: 1px; } QPushButton:hover{ background-image: url(./img/closeHover.png); } ''' btn_mini = ''' QPushButton{ background-image: url(./img/mini.png); border-radius: 1px; } QPushButton:Hover{ background-image: url(./img/miniHover.png) } ''' btn_max = ''' QPushButton{ background-image: url(./img/max.png); border-radius: 1px; } QPushButton:Hover{ background-image: url(./img/maxHover.png) } ''' headLabel = ''' QLabel{ background-color: #FFCCCC; border-radius: 4px; } ''' textButton = ''' QPushButton{ text-align: left; color: white; font: 20px "Times New Roman"; border-radius: 4px; } QPushButton:Hover{ color: #D6432D; } ''' writeButton = ''' QPushButton{ background-image: url(./img/blogWrite.png); border-radius: 4px; } QPushButton:Hover{ background-image: url(./img/blogWriteHover.png); } ''' threeWidget = ''' QWidget{ background-color: #222222; border-radius: 0px; } '''