File: PmwGroup.py.html

package info (click to toggle)
python-pmw 0.6.2-0.1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,652 kB
  • ctags: 2,716
  • sloc: python: 10,720; makefile: 44; sh: 24
file content (120 lines) | stat: -rw-r--r-- 4,135 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE HTML PUBLIC "-//Netscape_Microsoft//DTD HTML 3.0//EN">
<HTML>

<!-- This file generated using the Python HTMLgen module. -->
<HEAD>
  <META NAME="GENERATOR" CONTENT="HTMLgen 1.1">
        <TITLE>PmwGroup.py</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<PRE>
<FONT COLOR="#0000DD">"""
Module             PmwGroup.py

author             Case Roole &lt;cjr@bound.xs4all.nl&gt;
"""</FONT>

import string
import sys
import Tkinter
import Pmw

<STRONG>def aligngrouptags</STRONG>(groups):
    "Set the <FONT COLOR="#009900">'ringunits'</FONT> of the groups to one value."

    maxunit = max( map( lambda x: x.ringunit, groups ) )
    for group in groups:
	group.setringunit(maxunit)

<STRONG><FONT COLOR="#CC6600">class Group</FONT></STRONG>( Pmw.MegaWidget ):
<STRONG>    def __init__</STRONG>(self, parent = None, **kw):

        <FONT COLOR="#DD0000"># Define the megawidget options.</FONT>
	INITOPT = Pmw.INITOPT
        optiondefs = (
	    (<FONT COLOR="#009900">'ring_borderwidth'</FONT>, 2,         None),
	    (<FONT COLOR="#009900">'ring_relief'</FONT>,      <FONT COLOR="#009900">'groove'</FONT>,  None),
	    (<FONT COLOR="#009900">'ringpadx'</FONT>,         2,         INITOPT),
	    (<FONT COLOR="#009900">'ringpady'</FONT>,         2,         INITOPT),
	    )
        self.defineoptions(kw, optiondefs)

        <FONT COLOR="#DD0000"># Initialise the base class (after defining the options).</FONT>
        Pmw.MegaWidget.__init__(self, parent)

        <FONT COLOR="#DD0000"># Create the components.</FONT>
        interior = Pmw.MegaWidget.interior(self)
	self.oldInterior = interior

	self._ring = self.createcomponent(
	    <FONT COLOR="#009900">'ring'</FONT>, 
	    (), None,
	    Tkinter.Frame, (interior,), 
	    )

	self._groupChildSite = self.createcomponent(
	    <FONT COLOR="#009900">'groupchildsite'</FONT>,
	    (), None,
	    Tkinter.Frame, (self._ring,)
	    )

        unit = self.ringunit = self.createtag(self.component(<FONT COLOR="#009900">'hull'</FONT>))

	padx = self[<FONT COLOR="#009900">'ringpadx'</FONT>]
	pady = self[<FONT COLOR="#009900">'ringpady'</FONT>]
	self._ring.grid(column = 1, row = 1, sticky = <FONT COLOR="#009900">'nsew'</FONT>)
	interior.grid_columnconfigure(1, weight = 1)
	interior.grid_columnconfigure(0, minsize = padx)
	interior.grid_columnconfigure(2, minsize = padx)
	interior.grid_rowconfigure(1, weight = 1)
	interior.grid_rowconfigure(0, minsize = unit)
	interior.grid_rowconfigure(2, minsize = pady)

	self._groupChildSite.grid(column = 1, row = 1, sticky = <FONT COLOR="#009900">'nsew'</FONT>)
	self._ring.grid_columnconfigure(1, weight = 1)
	self._ring.grid_columnconfigure(0, minsize = padx)
	self._ring.grid_columnconfigure(2, minsize = padx)
	self._ring.grid_rowconfigure(1, weight = 1)
	self._ring.grid_rowconfigure(0, minsize = unit)
	self._ring.grid_rowconfigure(2, minsize = pady)

	#self._ring.pack(padx=self[<FONT COLOR="#009900">'ringpadx'</FONT>],
	#	pady=unit, expand=1,fill=<FONT COLOR="#009900">'both'</FONT>)
	#self._groupChildSite.pack(padx=self[<FONT COLOR="#009900">'ringpadx'</FONT>],
	#	pady=unit, expand=1,fill=<FONT COLOR="#009900">'both'</FONT>)
						    
        <FONT COLOR="#DD0000"># Check keywords and initialise options.</FONT>
        self.initialiseoptions(Group)

<STRONG>    def interior</STRONG>(self):
        return self._groupChildSite

<STRONG>    def createtag</STRONG>(self, parent ):

        self.tag = self.createcomponent(
	    <FONT COLOR="#009900">'tag'</FONT>,
	    (), None,
	    Tkinter.Label, (parent,),
	    )

	if self.tag is None:
	    return self[<FONT COLOR="#009900">'ringpady'</FONT>]

	unit = self.tag.winfo_reqheight()/2
	self.tag.place(x=unit,y=unit,anchor=<FONT COLOR="#009900">'w'</FONT>)
	return unit

<STRONG>    def setringunit</STRONG>(self,unit):
	self.ringunit = unit

	self.oldInterior.grid_rowconfigure(0, minsize = unit)
	self._ring.grid_rowconfigure(0, minsize = unit)
	<FONT COLOR="#DD0000">#self._ring.pack(pady=unit)</FONT>
	<FONT COLOR="#DD0000">#self._groupChildSite.pack(pady=unit)</FONT>

	self.tag.place(x=unit,y=unit,anchor=<FONT COLOR="#009900">'w'</FONT>)


</PRE>

 </BODY> </HTML>