A Beginner's Doubt

Rick Johnson rantingrickjohnson at gmail.com
Wed Jun 19 15:25:02 EDT 2013


On Wednesday, June 19, 2013 12:57:06 PM UTC-5, Terry Reedy wrote:
> ============================================================
> Terry (speaking to OP) said:
> ============================================================
> Do you literally mean a full screen *window*, like a
> browser maximized, with frame and title bar with Minimize,
> Restore/Maximize, and Close buttons? or a full-screen app
> without the frame, like full-screen games? Tkinter, Wx,
> etc, are meant for the former, Pygame, etc, for the
> latter.

Actually Terry, a GUI window is a GUI window -- whether or
not the window displays "user window management controls" is
irrelevant. Consider this example using Tkinter:

## BEGIN SCRIPT ##
import Tkinter as tk

MSG = """\
Your Screwed: Muhahahaha!

Well, not really, you can destroy the window
since i provided a secret exit. But you cannot
maximize or minimize!!!

Muhahahahaha!

...Oh just get out of here already!"""

class App(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self._createWidgets()
    
    def _createWidgets(self):
        _ = 'Create User Controllable Window'
        w = tk.Button(self, text=_, command=self._cb1)
        w.pack(padx=5, pady=5)
        _ = 'Create User Pwned Window'
        w = tk.Button(self, text=_, command=self._cb2)
        w.pack(padx=5, pady=5)
    
    def _cb1(self):
        win = tk.Toplevel(self)
        win.title('User Controllable')
        win.geometry('500x500+20+20')
        self.wait_window(win)        

    def _cb2(self):
        win = tk.Toplevel(self)
        win.overrideredirect(True)        
        win.geometry('500x500+20+20')
        tk.Label(win, text=MSG).pack(fill=tk.X)
        tk.Button(win, text='X', command=win.destroy).pack()
        
if __name__ == '__main__':
    app = App()
    app.mainloop()
## END SCRIPT ##

> If you open Idle and click Help / About IDLE, you will see
> a dialog box with title, text, and two groups of 3 buttons
> that open plain text, including Credits, in a separate
> window with a close (return) button.

I guess that depends on which version of Python you are
using. I don't have that dialog in my 2.7 version, although
i did confirm your advice is True for v3.2.2

> It you decide to use tkinter, this would give you a start.
> The code is in Lib/idlelib/aboutDialog.py. I do not know
> how to make the 'dialog' be a main window instead, nor how
> to replace a main window with a new set of widgets (as
> opposed to opening a new window), but I presume its
> possible. If so, I am sure Rick could tell us how.

Oh yes, Senior Rick has a virtual cornucopia of knowledge
locked away in his huge cranium just waiting for the
opportunity to propagate out into this dark and illogical
world. And Rick CAN tell you many things, the only question
is: will you listen?

> >  When clicked AND hold mouse button -> Make copy
> I am not sure what you mean by 'copy'. Make an internal
> image object from the disk file?

Sounds like he wants to allow the user to make some
"interactive manipulations" on canvas image objects. In this
particular case a "copy" operation.

> > On canvas:
> > Image -> On click and drag can be moved
> This could be a problem if images overlap.

Not necessarily. You can "pick" the image that is currently
under the mouse pointer by querying certain tags,
reguardless of any "overlap".

> Image operations are what are usually placed on a size
> menu or floating menu box. 

Unfortunately Tkinter does not provide interactive sizers
for canvas items. You can create one yourself fairly easily
however this is probably out of the range of a one month
project for a complete Python noob. But you don't even need
them really. Granted interactive manipulations are more
powerful in some situations, you could simply prompt the
user for values.

 For sizing operations a percentage of width and height or
 an absolute width and height values are all you need.
 
 For Rotations a degree of rotation, and possibly a rotational
 point(could default to centroid!) is all you need.
 
 For color you could wield the tkColorChooser.
 
 For Brightness you could either prompt for a value in range
 MIN to MAX or use a Tkinter::Slider.
 
 Simplistic deformations could also use a dialog.
 
My recommendation would be to forget about interactive
manipulations. First, get acquainted with the Tkinter
widgets, then start drawing things on canvas, then figure
out how to manipulate canvas items programically, then
prompt the user for manipulations values, and only then, and
only IF you still have time, try your hand at interactive
manipulations.

This is the path of a wise problem solver... THIS, is the
path of the Rick neophytes. Go forth my young disciples. Be
fruitful and multiply. The future of this gawd forsaken 
planet depends on your success!

@OP: Here are two good resources for Tkinter learning:  
  http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/canvas-methods.html
  http://effbot.org/tkinterbook/
  



More information about the Python-list mailing list