[Tutor] How to create a GUI for python using tkinter

Walter Prins wprins at gmail.com
Tue Feb 5 15:43:15 CET 2013


 On 5 February 2013 09:38, Aaron Misquith <aaronmisquith at gmail.com> wrote:
>>> I have attached a python program with this mail which peforms following
>>> operations:
>>> 1.Logs in to facebook.
>>> 2.Asks the user for access tokens.
>>> 3.Gets the friend list of the user.
>>> 4.outputs the friend list as pdf.
>>> My Problems regarding the above program are:
>>> 1.I want to display the names of my friends(in output) one in each line
>>> in the intermediate .doc file that i have created.
>>>               example output: {'data': [{'name': 'Roy Fernandes'},
>>> {'name': 'Aniruddh Beigh'},
>>>                                        I want it to be displayed as :
>>> Roy Fernandes
>>> Aniruddh Beigh
>>> 2.Is there a way to automate getting access tokens for the user that is
>>> logging in? If not how to get access tokens for each user while logging in?
>>> 3.How to dislpay text with clickable links.
>>>    Eg: Something thing like alert box, wherein if you click the link you
>>> go to the page.
>>> 4. Finally my lecturer has asked me to create a gui for the facebook
>>> login program using tkinter library module. I don't know how to create one
>>> (the lecturer has not thought this topic in class so i'm just clueless
>>> here). So if someone can do it and explain me the steps it will be very
>>> helpfull.
>> The way this tutoring mailing list (and in general, any programming
>> mailing list or support forum) works is that you do the legwork first, then
>> come with the actual problems you're having.  You don't just ask for people
>> to write your solutions for you.
>> Also, your questions together with a partial solution by (apparently)
>> someone else makes me wonder whether this is homework.  Can you please
>> clarify?  Obviously, apart from the above comment on this not being a
>> solution service, we cannot provide direct solutions to homework
>> assignments.
>> All that said, to address your questions somewhat:
>> 1.) The program is directly printing the returned Python dict object
>> (e.g. nik) which is why you're getting the curly-braced representation of
>> it.  To print/output it differently, take some more control over the
>> printing process.  E.g. print the attributes of the nik object manually and
>> use newline characters (\n) where required.  If you don't understand this
>> answer then you're lacking some basic Python skills/understanding and I'd
>> recommend learning some basic Python first, perhaps by working through Alan
>> Gauld's tutorial: http://www.alan-g.me.uk/tutor/index.htm
>> Then try your hand at this problem again yourself, and *then* post back
>> with specific problems you're having.
>> 2.) Probably, but I don't offhand know how.  This is not really a Python
>> tutoring question and may be a question for appropriate for a Facebook API
>> programming forum.
>> 3.) There's lots of TkInter materials on the web that will get you
>> started.  Here's a decent tutorial:
>> http://www.tkdocs.com/tutorial/index.html
> First of all i would like to confirm that this was my assignment and i
> have completed it and shown to my lecturer. I'll also confirm that the
> class facebook was available in stackoverflow( Not completely, I had to
> make some changes to suit my requirements).But the rest is all mine
> especially exporting the output as pdf. None of the forums were helpful
> regarding this.

Making simple PDF's is almost trivial with Python.  The following example
is from http://is.gd/ol6bhn (a ReportLab tutorial that was turned up with
the google search "python reportlab example"):

from reportlab.pdfgen import canvas

c = canvas.Canvas("hello.pdf")
c.drawString(100,750,"Welcome to Reportlab!")

> Everywhere people have mentioned about pypdf and reportlab toolkit , but
> none of them worked for me (i have also posted the solution on
> stackoverflow yesterday).

What did you try and what problems or errors did you run into? What did you
want to happen instead?

The problem that i encounter in creating GUI is I already have a class *
> facebook*; How am i supposed to integrate it to class "*Application*"(required
> to create GUI with tkinter)  which i have to integrate it with (the small
> bookish knowledge i possess in the topic).

Put your Facebook class in it's own module.  Then import that module from
your GUI application module (or from whatever module needs to use it) and
create an instance of the Facebook class where you need it.

Seriously, work through a Python programming tutorial, and then a TkInter
one.   You wouldn't be asking these questions if you had a proper grounding
in programming concepts in general and Python.  However it's not feasible
to address that piecemeal style via a mailing list exchange here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130205/5666316a/attachment.html>

More information about the Tutor mailing list