Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48743

Re: A Beginner's Doubt

Newsgroups comp.lang.python
Date 2013-06-19 12:25 -0700
References <8a4fced2-7d6c-455e-a482-b6f95b806ab5@googlegroups.com> <mailman.3593.1371664644.3114.python-list@python.org>
Message-ID <e17c63a6-00cf-409c-aea5-c4d02e46b805@googlegroups.com> (permalink)
Subject Re: A Beginner's Doubt
From Rick Johnson <rantingrickjohnson@gmail.com>

Show all headers | View raw


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/
  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A Beginner's Doubt augustofec@gmail.com - 2013-06-19 06:58 -0700
  Re: A Beginner's Doubt Neil Cerutti <neilc@norwich.edu> - 2013-06-19 14:19 +0000
  Re: A Beginner's Doubt Chris Angelico <rosuav@gmail.com> - 2013-06-20 00:20 +1000
  Re: A Beginner's Doubt Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-19 08:31 -0700
    Re: A Beginner's Doubt Joel Goldstick <joel.goldstick@gmail.com> - 2013-06-19 12:39 -0400
    Re: A Beginner's Doubt Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-19 19:34 +0100
    Re: A Beginner's Doubt Chris Angelico <rosuav@gmail.com> - 2013-06-20 01:40 +1000
  Re: A Beginner's Doubt Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-19 17:53 +0100
    Re: A Beginner's Doubt rusi <rustompmody@gmail.com> - 2013-06-19 10:29 -0700
  Re: A Beginner's Doubt Chris Angelico <rosuav@gmail.com> - 2013-06-20 03:01 +1000
  Re: A Beginner's Doubt Terry Reedy <tjreedy@udel.edu> - 2013-06-19 13:57 -0400
    Re: A Beginner's Doubt Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-19 12:25 -0700
  Re: A Beginner's Doubt augustofec@gmail.com - 2013-06-21 04:31 -0700

csiph-web