Пример #1
0
class Input(Frame):
    def __init__(self, Parent=None, Env=None):
        self.Name = 'Input'

        Frame.__init__(self, Parent)

        self.InputLabel = Label(self, text='Memory:',
                                font=Font(24))  #top label of input frame
        self.InputLabel.place(anchor='n', relx=HRel, relwidth=1,
                              relheight=0.1)  #placing the top label

        self.WarningLabel = Label \
            (
                self,
                text='attention:\ninserted memories can no longer be modified',
                font= Font(10),
                fg='#ff0000'
            ) #smaller red label
        self.WarningLabel.place(anchor='n',
                                relx=HRel,
                                rely=0.09,
                                relwidth=1,
                                relheight=0.04)  #placing the label

        self.MemoryInput = TextBox(
            self, font=Font(10))  #text box for memory insertion
        self.MemoryInput.place(anchor='n',
                               relx=HRel,
                               rely=0.15,
                               relwidth=0.98,
                               relheight=0.7)  #placing the textbox

        self.Submit = Button \
            (
                self,
                text='Create Memory',
                font = Font(20),
            ) #submition button to insert new memory
        self.Submit.place(anchor='n', relx=HRel, rely=0.8635,
                          relwidth=0.9)  #placing the button

        self.BackMenu = Button \
            (
                self,
                text='Back to menu',
                font=Font(10),
                command = lambda: Parent.Raise('Menu')
            ) #return at menu button and clean the text box
        self.BackMenu.place(anchor='n', relx=HRel, rely=0.945,
                            relwidth=0.9)  #placing the button
Пример #2
0
class View(Frame):
    def __init__(self, Parent=None, Env=None, Filter=-1):
        self.Name = 'View'

        Frame.__init__(self, Parent)

        self.TopViewFrame = Frame(self)  # frame for top label and search bar
        self.TopViewFrame.place(relx=0, rely=0, relwidth=1,
                                relheight=0.2)  # placing the frame top

        self.MemoriesFrame = MemoriesList(self)
        self.MemoriesFrame.place \
            (
                relx = 0,
                rely = 0.2,
                relwidth = 1,
                relheight = 0.745
            ) #placing the frame under the top frame

        self.BottomViewFrame = Frame(self)  #frame for back to menu
        self.BottomViewFrame.place(
            relx=0, rely=0.945, relwidth=1,
            relheight=0.1)  # placing the frame at the bottom

        #############################################################################################################Top

        self.MemoriesLabel = Label \
            (
                self.TopViewFrame,
                text='Your Memories:',
                font=('Courier', 32),
            ) #top label in top frame
        self.MemoriesLabel.place(anchor='n',
                                 relx=HRel,
                                 relwidth=1,
                                 relheight=0.7)  #placing the label

        self.SearchBar = TextBox(
            self.TopViewFrame,
            font=('Courier',
                  16))  #searchbar to search keywords in memories text
        self.SearchBar.place(anchor='n',
                             relx=HRel,
                             rely=0.7,
                             relwidth=0.99,
                             relheight=0.2)  #placing the search bar TODO

        self.SearchButton = Button \
            (
                self.TopViewFrame,
                text='Search',
                font=('Courier', 14),
            )  # button to research
        self.SearchButton.place(anchor='n',
                                relx=0.86,
                                rely=0.7225,
                                relwidth=0.25,
                                relheight=0.17)  #placing the button

        #########################################################################################################Top end
        ##########################################################################################################Bottom

        BackView = Button \
            (
                self.BottomViewFrame,
                text = 'Back to menu',
                font = ('Courier', 10),
                command = lambda: Parent.Raise('Menu')
            )  # return at menu button
        BackView.place(anchor='n', relx=HRel, rely=0.05,
                       relwidth=0.9)  # placing the button
Пример #3
0
def TKinterSetup():
    Root = EnvSetup()

    ################################################################################################################menu

    MenuFrame = Frame(Root)  #menu window area
    MenuFrame.place(relx=0, rely=0, relwidth=1,
                    relheight=1)  #placing the menu frame in the window

    MenuTopLabel = Label(MenuFrame,
                         text='Welcome to\nPositivity.Jar',
                         font=('Courier', 32),
                         bd=10)  #welcome label
    MenuTopLabel.place(anchor='n',
                       relx=HRel,
                       rely=0.015,
                       relwidth=1,
                       relheight=0.2)  #placing the label

    def ButtonSelection(Selection=int()):
        nonlocal Sel
        Sel = Selection

    Menu =\
        [
            Button
            (
                MenuFrame,
                text = 'Create new memory',
                font = ('Courier', 20),
                command = lambda : Raise(InputFrame) #raising a top level the input frame
            ),
            Button
            (
                MenuFrame,
                text = 'Show all memories of this year\n(random order)',
                font = ('Courier', 14),
                command = lambda : [ButtonSelection(0), Raise(ViewFrame)]
            ),
            Button
            (
                MenuFrame,
                text = 'Show all memories of this year\n(chronological order)',
                font=('Courier', 14),
                command = lambda : [ButtonSelection(1), Raise(ViewFrame)]
            ),
            Button
            (
                MenuFrame,
                text = "See all the memories of all year\n(random order)",
                font=('Courier', 14),
                command = lambda : [ButtonSelection(2), Raise(ViewFrame)]
            ),
            Button
            (
                MenuFrame,
                text = 'See all the memories of all year\n(chronological order)',
                font = ('Courier', 14),
                command = lambda: [ButtonSelection(3), Raise(ViewFrame)]
            )
        ] #list of buttons of the menu

    for i in range(len(Menu)):  #loop to place every button
        Menu[i].place\
            (
                anchor = 'n', #anchored at nord
                relx = HRel, #centered
                rely = 0.25 + (i * 0.125), #y position
                relwidth = 0.9 #% of window width
            )# placing the button

    ###############################################################################################################input

    InputFrame = Frame(Root)  # memory insertion frame
    InputFrame.place(relx=0, rely=0, relwidth=1,
                     relheight=1)  #placing the input frame

    InputLabel = Label(InputFrame, text='Memory:',
                       font=('Courier', 24))  #top label of input frame
    InputLabel.place(anchor='n', relx=HRel, relwidth=1,
                     relheight=0.1)  #placing the top label

    WarningLabel = Label\
        (
            InputFrame,
            text = 'attention:\ninserted memories can no longer be modified',
            font = ('Courier', 10),
            fg = '#ff0000'
        ) #smaller red label
    WarningLabel.place(anchor='n',
                       relx=HRel,
                       rely=0.09,
                       relwidth=1,
                       relheight=0.04)  #placing the label

    MemoryInput = TextBox(InputFrame,
                          font=('Courier', 16))  #text box for memory insertion
    MemoryInput.place(anchor='n',
                      relx=HRel,
                      rely=0.15,
                      relwidth=0.98,
                      relheight=0.7)  #placing the textbox


    Submit = Button\
        (
            InputFrame,
            text = 'Create Memory',
            font = ('Courier', 20),
            command = lambda : Confirmation(InsertMemory, MemoryInput.get(1.0), Text = 'Are you sure?')
        ) #submition button to insert new memory
    Submit.place(anchor='n', relx=HRel, rely=0.8635,
                 relwidth=0.9)  #placing the button

    BackInput = Button\
        (
            InputFrame,
            text = 'Back to menu',
            font = ('Courier', 10),
            command = lambda : [MemoryInput.delete(1.0, 'end'), Raise(MenuFrame)]
        ) #return at menu button and clean the text box
    BackInput.place(anchor='n', relx=HRel, rely=0.945,
                    relwidth=0.9)  #placing the button

    ###########################################################################################################memmories

    MemoOpts =\
        [
            [True, False], #random order, last year only
            [False, False], #chronological order, last year only
            [True, True], #random order, all years
            [False, False] ##chronological order, all years
        ] #parameters for a specific query of the database

    MemoriesDB = lambda x: ShowMemories(MemoOpts[x][0], MemoOpts[x][
        1])  # memories of the db based on user options
    Sel = int()
    Memories = MemoriesDB(Sel)

    ViewFrame = Frame(Root)  #memory view root frame
    ViewFrame.place(relx=0, rely=0, relwidth=1,
                    relheight=1)  #placing the frame in the window

    TopViewFrame = Frame(ViewFrame)  #frame for top label and search bar
    TopViewFrame.place(relx=0, rely=0, relwidth=1,
                       relheight=0.2)  #placing the frame top

    ListFrame = Frame(ViewFrame)  #canvas for memories in database
    ListFrame.place(relx=0, rely=0.2, relwidth=1,
                    relheight=0.745)  #placing the frame under the top frame

    BottomViewFrame = Frame(ViewFrame)  #frame for back to menu
    BottomViewFrame.place(relx=0, rely=0.945, relwidth=1,
                          relheight=0.1)  #placing the frame at the bottom

    MemoriesLabel = Label\
        (
            TopViewFrame,
            text = 'Your Memories:',
            font = ('Courier', 32),
        ) #top label in top frame
    MemoriesLabel.place(anchor='n', relx=HRel, relwidth=1,
                        relheight=0.7)  #placing the label

    SearchBar = TextBox(
        TopViewFrame,
        font=('Courier', 16))  #search bar to search keywords in memories text
    SearchBar.place(anchor='n',
                    relx=HRel,
                    rely=0.7,
                    relwidth=0.99,
                    relheight=0.2)  #placing the searchbar TODO

    SearchButton = Button\
        (
            TopViewFrame,
            text = 'Search',
            font = ('Courier', 14),
            command = lambda : None
        ) #botton to research
    SearchButton.place(anchor='n',
                       relx=0.86,
                       rely=0.7225,
                       relwidth=0.25,
                       relheight=0.17)  #placingthe button

    SBar = Bar(ListFrame, orient='vertical')
    ListMemoryBox = ListBox\
        (
            ListFrame,
            selectmode = 'browse',
            bg = '#ffffff',
            activestyle = 'none',
            font = ('Courier', 14),
            selectbackground = '#e0e0e0'
        )
    ListMemoryBox.place(anchor='n',
                        relx=HRel,
                        rely=0,
                        relwidth=0.99,
                        relheight=1)

    for i in ['a' for i in range(255)]:
        ListMemoryBox.insert('end', i)

    BackView = Button\
        (
            BottomViewFrame,
            text = 'Back to menu',
            font = ('Courier', 10),
            command = lambda: Raise(MenuFrame)
        )  #return at menu button
    BackView.place(anchor='n', relx=HRel, rely=0.05,
                   relwidth=0.9)  #placing the button

    Raise(MenuFrame)  #raising the menu as first viewed frame
    return Root