Esempio n. 1
0
#! /usr/bin/python
#-*- coding: utf-8 -*-

import sys
import os
from PyQt4 import QtGui
from form import Form

if __name__ == "__main__":

    app = QtGui.QApplication(sys.argv)
    app.setApplicationName("debo")

    myapp = Form()
    myapp.show()
    sys.exit(app.exec_())
Esempio n. 2
0
    def on_show(self):
        FORMAT = '%(asctime)s - %(levelname)s: %(message)s'
        logging.basicConfig(format=FORMAT, level=logging.DEBUG)

        log = logging.getLogger('tkplus-demo')

        def cool2():
            print "GREETZ"

        def cool():
            global f
            messagebox.show('hello world')
            f1 = Form(caption="New Form", left=320, top=200)
            btn1 = Button(f1, caption='Hello', left=5, top=5, width=200, height=100)
            btn1.on_click = cool2
            btn1.background = 'blue'
            f1.show_modal()
            print "I'm a cool app"

        log.debug('demo app starting')
        f = Form(caption="Hello", width=640, height=480)
        f.caption = "Greetings"
        f.resizable = True
        f.form_type = SINGLE

        #img = Image(f, left=0, top=0, width=400, height=400, file='ok.gif')
        #img2 = Image(f, left=20, top=20, width=30, height=30, file='ok.gif')
    
        b = Button(f, caption="&Click Me", left=0, top=0, width=120, height=35)
        b.on_click = cool
        b.default = True

        b2 = Button(f, caption="Click &Me 2", left=0, top=40, width=120, height=35)
        
        def on_new():
            print "HELLO"
            messagebox.show("NEW FILE")

        menu = MainMenu(f)
        filemenu = menu.create("File")
        filemenu.create("New", on_click=on_new)
        filemenu.separator()
        filemenu.create("Exit", on_click=f.close)

        def close_notify():
            print "CLOSING"

        popup1 = PopupMenu(f)
        popup1.create("Click me", on_click=on_new)

        popup2 = PopupMenu(f)

        dlg = OpenDialog(f)
        dlg.multiple = True
        dlg.title = 'Pick a file'
        dlg.filter = 'Text Documents|*.txt'
        def raise_ex():
            raise ValueError('If I had a nickel for every exception that was thrown...')
        b2.on_click = raise_ex

        #f.icon = 'notepad.ico'

        tv1 = TreeView(f, top=80, left=5, width=600, height=300)
        item = tv1.items.add('C:')
        item.add('Documents and Settings')
        item.add('Users').add('Todd Suess').add('Desktop')
        item.add('Windows').add('system32')

        sb = StatusBar(f)

        f.left, f.top = 0, 0
        f.show()
Esempio n. 3
0
#! /usr/bin/python
#-*- coding: utf-8 -*-

import sys
import os
from PyQt4 import QtGui
from form import Form


if __name__ == "__main__":

    app = QtGui.QApplication(sys.argv)
    app.setApplicationName("debo")

    myapp = Form()
    myapp.show()
    sys.exit(app.exec_())
Esempio n. 4
0
class Main(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.addButton.clicked.connect(self.add_notif)
        self.pushButton.clicked.connect(self.show_notif)
        self.params = {
            "Пропущенные": "show_missed",
            "Предстоящие по времени": "show_by_time",
            "Предстоящие по приоритету": "show_by_prior"
        }
        self.comboBox.addItems(list(self.params.keys()))
        self.inter = Interactor(DB_NAME, TABLE_NAME)
        self.delete_missed_btn.clicked.connect(self.delete_missed)

    def add_notif(self):
        self.next = Form()
        self.next.show()

    def delete_missed(self):
        self.inter.delete_req(f"""DELETE FROM {TABLE_NAME} WHERE DATETIME(date_time) < DATETIME('now')""")
        show_info("Пропущенные напоминания удалены")

    def show_notif(self):
        func = self.params.get(self.comboBox.currentText())
        if func == "show_missed":
            self.show_missed()
        if func == "show_by_time":
            self.show_by_time()
        if func == "show_by_prior":
            self.show_by_prior()

    def clear_layout(self, layout):
        for i in range(layout.count()):
            layout_item = layout.itemAt(i)
            if layout_item and layout_item.__class__.__name__ == "QHBoxLayout":
                deleteItemsOfLayout(layout_item.layout())
                layout.removeItem(layout_item)
            elif not layout_item:
                self.clear_layout(layout.layout())

    def convert_to_layout(self, item):
        res = QHBoxLayout()
        lbl1 = QLabel()
        lbl1.setText(" ".join(
            ["Название: " + item[0], "   Приоритет: " + str(item[1]), "   Дата и время: " + item[2] + "   Картинка"]))
        res.addWidget(lbl1)
        lbl2 = QLabel()
        if item[3] != self.inter.alt_img:
            name = item[3]
            os.chdir("media")
            pixmap = QPixmap(name)
            pixmap = pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio)
            os.chdir("..")
            lbl2.setPixmap(pixmap)
            lbl2.resize(100, 100)
            res.addWidget(lbl2)
        else:
            lbl1.setText(lbl1.text() + " " + self.inter.alt_img)
        return res

    def add_notifs_to_layout(self, arr):
        self.clear_layout(self.notifications_layout)
        if len(list(arr)) == 0:
            show_info("Напоминаний не найдено")
        for i in arr:
            self.notifications_layout.addLayout(self.convert_to_layout(i))

    def show_missed(self):
        res = self.inter.get("""SELECT * FROM {} WHERE DATETIME(date_time) < DATETIME('now')""".format(TABLE_NAME))
        self.add_notifs_to_layout(res)

    def show_by_time(self):
        res = self.inter.get(
            """SELECT * FROM {} WHERE DATETIME(date_time) > DATETIME('now') ORDER BY date_time""".format(TABLE_NAME))
        self.add_notifs_to_layout(res)

    def show_by_prior(self):
        res = self.inter.get(
            """SELECT * FROM {} WHERE DATETIME(date_time) > DATETIME('now') ORDER BY prior""".format(TABLE_NAME))
        self.add_notifs_to_layout(res)