PythonWin,Slider control....

Mike Fletcher mcfletch at vrtelecom.com
Mon Sep 27 11:34:04 EDT 1999


Well, here's an example, doesn't do anything (I just ripped it out of one of
my projects, replacing an OLE control with the slider and calling the
CreateWindow method instead of CreateControl.

*Mark* The docs for win32ui.CreateSliderCtrl for some reason say to use
PySliderCtrl::Create which doesn't exist.  The docs for PySliderCtrl
correctly name the creation function as CreateWindow (though why it's
different from the OLE control I do not know).  Feel free to include the
(rather trivial) demo below if you would like to do so.

Cheers, and hope this helps,
Mike

(There are wrapping problems in the code, but you should be able to figure
those out :) )...
8<_____________________________ exampleslider.py ______________
import win32con, win32ui
from pywin.mfc import dialog

class MyDialog(dialog.Dialog):
	'''
	Example using simple controls
	'''
	_dialogstyle = (win32con.WS_MINIMIZEBOX | win32con.WS_DLGFRAME |
win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE |
win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT )
	_buttonstyle = (win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP |
win32con.WS_CHILD | win32con.WS_VISIBLE)
	### The static template, contains all "normal" dialog items
	DIALOGTEMPLATE = [
		# the dialog itself is the first element in the template
		["Example slider", (0, 0, 50, 43), _dialogstyle, None, (8, "MS Sans
Serif")],
		# rest of elements are the controls within the dialog
		# standard "Close" button
		[128, "Close", win32con.IDCANCEL, (0, 30, 50, 13), _buttonstyle],
	]
	### ID of the control to be created during dialog initialisation
	IDC_SLIDER = 9500
	def __init__(self ):
		dialog.Dialog.__init__(self, self.DIALOGTEMPLATE)
	def OnInitDialog(self):
		rc = dialog.Dialog.OnInitDialog(self)
		# now initialise your controls that you want to create
		# programmatically, including those which are OLE controls
		# those created directly by win32ui.Create*
		# and your "custom controls" which are subclasses/whatever
		win32ui.EnableControlContainer()
		self.slider = win32ui.CreateSliderCtrl( )
		self.slider.CreateWindow( win32con.WS_TABSTOP | win32con.WS_VISIBLE,
			(0,0,100,30),
			self._obj_,
			self.IDC_SLIDER
		)
		return rc
###
if __name__ == "__main__":
	dia = MyDialog()
	dia.DoModal()

-----Original Message-----
From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On
Behalf Of BGV
Sent: September 26, 1999 11:50 AM
To: python-list at cwi.nl
Subject: PythonWin,Slider control....


Has anyone managed to generate a window with a slider control in PythonWin
using
CreateSliderCtrl in win32ui? I can't seem to get it to work.

TIA

BGV










More information about the Python-list mailing list