File: PmwCounterDialog.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 (67 lines) | stat: -rw-r--r-- 2,516 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
<!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>PmwCounterDialog.py</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<PRE>
import Pmw

<FONT COLOR="#DD0000"># A Dialog with a counter</FONT>

<STRONG><FONT COLOR="#CC6600">class CounterDialog</FONT></STRONG>(Pmw.Dialog):

<STRONG>    def __init__</STRONG>(self, parent = None, **kw):

	<FONT COLOR="#DD0000"># Define the megawidget options.</FONT>
	INITOPT = Pmw.INITOPT
	optiondefs = (
	    (<FONT COLOR="#009900">'borderx'</FONT>,    20,  INITOPT),
	    (<FONT COLOR="#009900">'bordery'</FONT>,    20,  INITOPT),
	)
	self.defineoptions(kw, optiondefs)

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

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

	<FONT COLOR="#DD0000"># Create the counter.</FONT>
	aliases = (
	    (<FONT COLOR="#009900">'entryfield'</FONT>, <FONT COLOR="#009900">'counter_entryfield'</FONT>),
	    (<FONT COLOR="#009900">'entry'</FONT>, <FONT COLOR="#009900">'counter_entryfield_entry'</FONT>),
	    (<FONT COLOR="#009900">'label'</FONT>, <FONT COLOR="#009900">'counter_label'</FONT>)
	)
	self._cdCounter = self.createcomponent(<FONT COLOR="#009900">'counter'</FONT>,
		aliases, None,
		Pmw.Counter, (interior,))
	self._cdCounter.pack(fill=<FONT COLOR="#009900">'x'</FONT>, expand=1,
		padx = self[<FONT COLOR="#009900">'borderx'</FONT>], pady = self[<FONT COLOR="#009900">'bordery'</FONT>])
	
	<FONT COLOR="#DD0000"># Whenever this dialog is activated, set the focus to the</FONT>
	<FONT COLOR="#DD0000"># Counter's entry widget.</FONT>
	tkentry = self.component(<FONT COLOR="#009900">'counter_entryfield_entry'</FONT>)
	self.configure(activatecommand = tkentry.focus_set)

	<FONT COLOR="#DD0000"># Check keywords and initialise options.</FONT>
	self.initialiseoptions(CounterDialog)

    <FONT COLOR="#DD0000"># Need to override Dialog insert and delete with Counter methods</FONT>
<STRONG>    def insertentry</STRONG>(self, index, text):
	self._cdCounter.insert(index, text)

<STRONG>    def deleteentry</STRONG>(self, first, last=None):
	self._cdCounter.delete(first, last)

<STRONG>    def indexentry</STRONG>(self, index):
	return self._cdCounter.index(index)

Pmw.forwardmethods(CounterDialog, Pmw.Counter, <FONT COLOR="#009900">'_cdCounter'</FONT>)

</PRE>

 </BODY> </HTML>