Newbie need help to build a tkinter task manager !

Post here if you need help with creating a Graphical User Interface in Python.

Newbie need help to build a tkinter task manager !

Postby ibrahim123 » Fri May 17, 2013 12:08 am

Hey guys, I'm completely new to tkinter but I am trying to create a simple task manager. All it does is it allows the user to enter a task with the date and time and it stores the task in a label that can be viewed and later edited/deleted. On paper it would look something like this:

Image

Check buttons are used to be able to select which task to be edited/deleted. Unless someone comes up with something easier/simple i will stick with this.

I have already started working on it. Its not much but this is what i have til now:

Code: Select all
import sys
from Tkinter import *
mGui = Tk()

mGui.geometry("450x450+400+100")
mGui.title("Task manager")

def inputl():
    ltext = firstT.get()
    label1 = Label(mGui,text=ltext).pack()
    return


firstT=StringVar()
   
message = "Enter task"
Label(mGui, text=message).pack()
entry1= Entry(mGui, textvariable=firstT).pack()
Button1 = Button(mGui, text='OK', command=inputl).pack()
   


Button(mGui, text="Add", command=inputl).pack(side=TOP, ipadx=50)
Button(mGui, text="Edit").pack(side=TOP, ipadx=51)
Button(mGui, text="Delete").pack(side=TOP, ipadx=44) 

mGui.mainloop()



I would appreciate it if I could get some help to finish this program ASAP. Thanks a lot !
Last edited by micseydel on Fri May 17, 2013 12:36 am, edited 1 time in total.
Reason: Added code tags.
ibrahim123
 
Posts: 3
Joined: Thu May 16, 2013 11:36 pm

Re: Newbie need help to build a tkinter task manager !

Postby metulburr » Fri May 17, 2013 2:05 am

What help are you exactly looking for?

its been a while since i did tkinter, but i think the method best would be to make a Frame() and set the frame to be centered down, then set the labels of the tasks to the left of that frame, and the check box to the right of that frame. Of course you really didnt mention what you were looking for to begin with so i cant help you much
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1512
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Newbie need help to build a tkinter task manager !

Postby ibrahim123 » Fri May 17, 2013 7:29 am

Im having trouble linking the check buttons with my labels and the edit/delete button. So when I have one check button next to one of the labels active, and I press either the delete or edit, it will allow me to edit/delete whatever is in that specific label.
ibrahim123
 
Posts: 3
Joined: Thu May 16, 2013 11:36 pm

Re: Newbie need help to build a tkinter task manager !

Postby wuf » Fri May 17, 2013 8:31 pm

Hi ibrahim123

Here one solution:
Code: Select all
import sys
from Tkinter import *

BUTTON_WIDTH = 20
LABEL_WIDTH = 16
PADY = 4

mGui = Tk()

mGui.geometry("450x450+400+100")
mGui.title("Task manager")

def inputl():
    ltext = firstT.get()
    label1 = Label(mGui,text=ltext).pack()
    return

def edit():
    firstT.set(task_var_list[radio_button_var.get()].get())
   
def add():
    task_var_list[radio_button_var.get()].set(firstT.get())
   
def delete():
    firstT.set('')
    task_var_list[radio_button_var.get()].set('')
   
firstT=StringVar()
   
message = "Enter task"
Label(mGui, text=message).pack(pady=PADY)
entry1= Entry(mGui, textvariable=firstT).pack(pady=PADY)
Button1 = Button(mGui, text='OK', command=inputl).pack(pady=PADY)
   
Button(mGui, text="Add", width=BUTTON_WIDTH, command=add).pack(pady=PADY)
Button(mGui, text="Edit", width=BUTTON_WIDTH, command=edit).pack(pady=PADY)
Button(mGui, text="Delete", width=BUTTON_WIDTH, command=delete).pack(pady=PADY)

TASKS = ['Task-01', 'Task-02', 'Task-03', 'Task-04']
radio_button_var = IntVar()
task_var_list = list()
 
for index, task in enumerate(TASKS):
    var = StringVar()
    var.set(task)
    frame = Frame(mGui)
    frame.pack(pady=4)
    Label(frame, textvar=var, width=LABEL_WIDTH, bg='white').pack(side='left')
    Radiobutton(frame,
        variable=radio_button_var, value=index).pack(side='left')
    task_var_list.append(var)

mGui.mainloop()

wuf ;)
wuf
 
Posts: 42
Joined: Fri Feb 08, 2013 6:42 am

Re: Newbie need help to build a tkinter task manager !

Postby ibrahim123 » Sat May 18, 2013 6:08 pm

WOW thank you so much ! this is exactly what i wanted. One thing though, how would i go about adding one more column next to the labels so that the user can enter the date for each one ?
ibrahim123
 
Posts: 3
Joined: Thu May 16, 2013 11:36 pm

Re: Newbie need help to build a tkinter task manager !

Postby Yoriz » Sat May 18, 2013 6:17 pm

You should consider examining the code thats been given to you and then attempt to add one more column next to the labels yourself.
Then come back and ask questions about the problems you get with your code atempt, then you will learn and be able to atempt future changes that become necessary.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Image
User avatar
Yoriz
 
Posts: 1052
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to GUI

Who is online

Users browsing this forum: No registered users and 1 guest