[Tutor] Tutor Digest, Vol 95, Issue 80

Arun Kumar arunkumar413 at gmail.com
Mon Jan 30 16:13:32 CET 2012


Dear Ganesh,

Glade is just an user interface builder. It is just a Rapid Application
Development (RAD) tool that simplifies designing the user interface. But
you still need to program what the interface does. This is done by PyGTK, a
toolkit, or a collection of libraries, which developers can use to develop
GUI applications for Linux, OSX, Windows, and any other platform on which
GTK+ is available. I think this tutorial may be helpful to you.

http://www.micahcarrick.com/gtk-glade-tutorial-part-1.html
http://www.pygtk.org/pygtk2tutorial/index.html

On Mon, Jan 30, 2012 at 1:23 PM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>        tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>        tutor-request at python.org
>
> You can reach the person managing the list at
>        tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. Re: Deleting an object (Peter Otten)
>   2. Re: Deleting an object (Alan Gauld)
>   3. Re: Socket Programming (Navneet)
>   4. Re: Why do you have to close files? (amt)
>   5. loop until a keypress (Surya K)
>   6. Help Glade Tutorial. (Ganesh Kumar)
>   7. Re: Help Glade Tutorial. (Chris Fuller)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 29 Jan 2012 17:34:12 +0100
> From: Peter Otten <__peter__ at web.de>
> To: tutor at python.org
> Subject: Re: [Tutor] Deleting an object
> Message-ID: <jg3se3$seo$1 at dough.gmane.org>
> Content-Type: text/plain; charset="ISO-8859-1"
>
> George Nyoro wrote:
>
> >        Last time I tried to post a question regarding this, I was asked
> to
> > clarify. Okay so here it is. There is a class called Table and objects
> are
> > just tables, you know, matrices, holding different types of data. Thing
> > is, I want to provide a method where one can delete the object and then
> if
> > the user tries using a variable to access a certain method or attributes,
> > he gets an error. Let me give an example;
> >
> > class Table:
> >     def delete_this(self):
> >         #code to delete this object or assign it null or None
> >         pass
> >
> >     def do_something(self):
> >         pass
>
> > x=Table()
> > x.delete_this()
> >
> > #at this point, I want such that if I try to use x I get some sort of
> > #error
> > e.g.
> >
> > x.do_something()
> >
> > #Error: x is definitely not an object anymore
> >
> >
> >  All clear?
>
>
> >>> class Parrot:
> ...     def hello(self):
> ...             print("Hello")
> ...     def delete_this(self):
> ...             self.__class__ = DeadParrot
> ...
> >>> class DeadParrot:
> ...     def __getattr__(self, name):
> ...             raise Exception("This parrot is no more")
> ...
> >>> p = Parrot()
> >>> p.hello()
> Hello
> >>> p.delete_this()
> >>> p.hello()
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 3, in __getattr__
> Exception: This parrot is no more
>
> But I don't think it's a good idea...
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 29 Jan 2012 18:05:59 +0000
> From: Alan Gauld <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Deleting an object
> Message-ID: <jg41q7$6lq$1 at dough.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 29/01/12 15:14, George Nyoro wrote:
>
> > data. Thing is, I want to provide a method where one can delete the
> > object and then if the user tries using a variable to access a certain
> > method or attributes, he gets an error. Let me give an example;
>
> I assume you know about the built in del() function that deletes
> objects? It works on any kind of object.
>
> If you need it to do sometjing fancy(like releasing resources say) you
> can define your own __del__() method that gets called by Python when the
> object is deleted - but you rarely need to do that in Python.
>
> > class Table:
> >    def delete_this(self):
> >    def do_something(self):
>
> > x=Table()
> > x.delete_this()
> > #at this point, I want such that if I try to use x I get some sort of
> > error e.g.
>
> x = Table()
> del(x)
>
> now referencing x or any attribute or method will give a name error.
> Here is an example using an int, but any kind of object works:
>
>  >>> x = 42
>  >>> x
> 42
>  >>> del(x)
>  >>> x
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'x' is not defined
>  >>>
>
> If thats not what you want you need to come vback and explain what is
> different about your scenario.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 29 Jan 2012 21:01:47 +0100
> From: Navneet <rocklearnpython at gmail.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Socket Programming
> Message-ID: <4F25A5AB.5070903 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 1/27/2012 10:13 PM, Steven D'Aprano wrote:
> > Navneet wrote:
> >
> >> One more thing I want to add here is, I am trying to create the GUI
> >> based chat server.(Attached the programs.)
> >
> >
> > Please do not send large chunks of code like this, unless asked.
> > Instead, you should try to produce a minimal example that demonstrates
> > the problem. It should be:
> >
> > * short (avoid code which has nothing to do with the problem)
> >
> > * self-contained (other people must be able to run it)
> >
> > * correct (it must actually fail in the way you say it fails)
> >
> > See here for more: http://sscce.org/
> >
> >
> > In cutting your code down to a minimal example, 9 times out of 10 you
> > will solve your problem yourself, and learn something in the process.
> >
> >
> >> bash-3.1$ python Client1.py
> >> Enter the server address:...9009
> >> Traceback (most recent call last):
> >>   File "Client1.py", line 53, in <module>
> >>     c = ClientChat(serverport)
> >>   File "Client1.py", line 24, in __init__
> >>     gui.callGui()
> >>   File "a:\FedEx\Exp\ClientGui.py", line 37, in callGui
> >>     sendbutton =Button(f2, width = 5, height = 2, text = "Send",
> >> command = C.ClientChat.senddata())
> >> TypeError: unbound method senddata() must be called with ClientChat
> >> instance as first argument (got nothing instead)
> >
> >
> > This one is easy. You need to initialize a ClientChat instance first.
> > This may be as simple as:
> >
> > command = C.ClientChat().senddata
> >
> > although I'm not sure if ClientChat requires any arguments.
> >
> > Note that you call the ClientChat class, to create an instance, but
> > you DON'T call the senddata method, since you want to pass the method
> > itself as a callback function. The button will call it for you, when
> > needed.
> >
> >
> >
> Thanks for the clarification and telling me about SSCCE :)
>
> But just a simple thing,,, Can I call a method of another module while
> creating a GUI.
>
> For example
>  C = Tk()
> .....(Some more lines)
> self.sendbutton =Button(self.f2, width = 5, height = 2, text = "Send",
> command = <ANOTHER MODULE>.<METHOD OF THAT MODULE>)
>         self.sendbutton.pack(side = LEFT, padx = 10, pady = 10)
> .....(Some more lines)
> C.mainloop()
>
>
> Because I am getting stuck in a loop. The client is keep on connecting
> to server without creating a GUI.
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Mon, 30 Jan 2012 00:28:21 +0200
> From: amt <0101amt at gmail.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Why do you have to close files?
> Message-ID:
>        <CAEQEn016afJDN+2F_+R-rm2d4MbWGXvN9_ed-AQoNmT=F2VKiQ at mail.gmail.com
> >
> Content-Type: text/plain; charset=ISO-8859-1
>
> All the replies were very helpful! Thank you very much for helping me out!
>
>
> ------------------------------
>
> Message: 5
> Date: Mon, 30 Jan 2012 10:50:51 +0530
> From: Surya K <suryak at live.com>
> To: Python Tutor <tutor at python.org>
> Subject: [Tutor] loop until a keypress
> Message-ID: <SNT130-W397E068F9E47ABD82EEA34A48D0 at phx.gbl>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> I want to run code until a "enter" is pressed. Well, it shouldn't wait for
> the user to enter "enter"
> This is my code:
> import msvcrtchr = 0while chr != 'q':     print "my code",     if
> msvcrt.kbhit():           chr = msvcrt.getch()
> This isn't working the way I wanted. When ever I press enter, the loop is
> starting in a new line and continuing.
> I even added "break" statement in "if" block but it isn't workingCan you
> tell me how to do that?
> I am on windows. So, as msvcrt is for windows, I wonder if there is any
> module that works for both,
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20120130/a5996b2a/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 6
> Date: Mon, 30 Jan 2012 11:55:12 +0530
> From: Ganesh Kumar <bugcy013 at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] Help Glade Tutorial.
> Message-ID:
>        <CAJzooYc-OaR6JOz9WRJBtv0W6t3L2ZL0dZV+GUyD-yUP9xe-JQ at mail.gmail.com
> >
> Content-Type: text/plain; charset="utf-8"
>
> Hi Guys,
>
> I am searching for a Glade tutorial, on how to create simple projects Glade
> with python
>
> 1) design a simple interface in glade
> 2) use the glade interface to write some really simple application with
> python.
>
> I search in goggled i didn't get good tutorials, guide me guys How to start
> with Glade.
>
> -Ganesh
>
> Did I learn something today? If not, I wasted it.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20120130/fec2e0a2/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 7
> Date: Mon, 30 Jan 2012 00:51:58 -0600
> From: Chris Fuller <cfuller084 at thinkingplanet.net>
> To: tutor at python.org
> Subject: Re: [Tutor] Help Glade Tutorial.
> Message-ID: <201201300051.58828.cfuller084 at thinkingplanet.net>
> Content-Type: Text/Plain;  charset="utf-8"
>
>
> Which ones did you look at, and why did you not like them?  Keep in mind
> that
> Glade is an interface builder, and hasn't got anything much to do with the
> target language, other than requiring there be a libglade library to read
> the
> XML files.
>
> I actually got started with some articles in Linux Journal, which don't
> appear
> high on the google search unless you include those terms.  Search for
> "glade
> tutorial" or "glade linux journal".  Leave Python or pyGTK out of your
> search
> for now.
>
> You might need a little help with using the XML files glade produces, but
> that's covered in the pyGTK documentation.  It's also in the Linux Journal
> articles.  You can google "pygtk glade" if you need more.
>
> Cheers
>
> On Monday 30 January 2012, Ganesh Kumar wrote:
> > Hi Guys,
> >
> > I am searching for a Glade tutorial, on how to create simple projects
> Glade
> > with python
> >
> > 1) design a simple interface in glade
> > 2) use the glade interface to write some really simple application with
> > python.
> >
> > I search in goggled i didn't get good tutorials, guide me guys How to
> start
> > with Glade.
> >
> > -Ganesh
> >
> > Did I learn something today? If not, I wasted it.
>
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 95, Issue 80
> *************************************
>



-- 
Thanks & Regards,

Arun Kumar
http://clicknscroll.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120130/007e3ea2/attachment-0001.html>


More information about the Tutor mailing list