473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Tkinter cursor question

I would like to define a new cursor for use on a Canvas (other than one of
those listed in Appendix F of "Python and Tkinter Programming"). A search on
Google turned up one bit of code that seemed promising. A slightly
simplified version is shown below. This code attempts to eliminate the
cursor by defining an invisible one, which is not what I want, but I thought
it might be a start. However, it doesn't run; the statement t = Text(...)
generates an error message: TclError: bad cursor spec "@testcursor white".
The testcursor file is being created in the current directory.

How can this code be corrected? Where can I find more information on
creating a cursor?

I'm using ActivePython 2.2 Build 224

Thanks,
Gary Richardson
---------------------------
# From a post to c.l.p by Matthew Dixon Cowles on 17 Jul 2002.
from Tkinter import *
import os
kNullCursorData="""
#define t_cur_width 1
#define t_cur_height 1
#define t_cur_x_hot 0
#define t_cur_y_hot 0
static unsigned char t_cur_bits[] = { 0x00};
"""
root=Tk()
os.umask(0177) # octal
fn = "testcursor"
f=open(fn,"w")
f.write(kNullCursorData)
f.close()
t=Text(root,bg="white",cursor="@testcursor white")
t.pack()
root.mainloop()


Jul 18 '05 #1
3 5881

"Gary Richardson" <ga***@fidalgo.net> schrieb im Newsbeitrag
news:vm***********@corp.supernews.com...
I would like to define a new cursor for use on a Canvas (other than one of
those listed in Appendix F of "Python and Tkinter Programming"). A search on Google turned up one bit of code that seemed promising. A slightly
simplified version is shown below. This code attempts to eliminate the
cursor by defining an invisible one, which is not what I want, but I thought it might be a start. However, it doesn't run; the statement t = Text(...)
generates an error message: TclError: bad cursor spec "@testcursor white".
The testcursor file is being created in the current directory.

This is rather tricky - you will have to look through Tcl manuals, e.g.:

http://dev.scriptics.com/man/tcl8.3/TkLib/GetCursor.htm
You find there:

@sourceName maskName fgColor bgColor
In this form, sourceName and maskName are the names of files describing
cursors for the cursor's source bits and mask. Each file must be in standard
X11 or X10 cursor format. FgColor and bgColor indicate the colors to use for
the cursor, in any of the forms acceptable to Tk_GetColor. This form of the
command will not work on Macintosh or Windows computers.

@sourceName fgColor
This form is similar to the one above, except that the source is used as
mask also. This means that the cursor's background is transparent. This form
of the command will not work on Macintosh or Windows computers.

@sourceName
This form only works on Windows, and will load a Windows system cursor
(.ani or .cur) from the file specified in sourceName.

Kindly
MichaelP
Jul 18 '05 #2
[snip]

@sourceName
This form only works on Windows, and will load a Windows system cursor
(.ani or .cur) from the file specified in sourceName.

Kindly
MichaelP

Michael,

Thanks for your reply. I am using Windows so I guess I'm out of luck as far
as designing my own cursor. I tried the form that is supposed to work with
windows but no luck with that either. The code below produces the error
message: TclError: bad cursor spec "@CROSS_M.CUR". I also tried using the
full pathname ("@C:\windows\cursors\cross_m.cur" and
"@c:\\windows\\cursors\\CROSS_M.CUR") but the result was the same. Any
further advice?

Thanks,
Gary Richardson
-------------
from Tkinter import *
root=Tk()
Text(root,bg="white",cursor="@CROSS_M.CUR").pack()
root.mainloop()



Jul 18 '05 #3

"Gary Richardson" <ga***@fidalgo.net>
[snip]

@sourceName
This form only works on Windows, and will load a Windows system cursor (.ani or .cur) from the file specified in sourceName.
Michael,

Thanks for your reply. I am using Windows so I guess I'm out of luck as far as designing my own cursor. I tried the form that is supposed to work with
windows but no luck with that either. The code below produces the error
message: TclError: bad cursor spec "@CROSS_M.CUR". I also tried using the


Gary,
seems it totally ignores the leading @ - always looking for a built-in
name....
I used bitmaps some time ago (...,bitmap='@file',.. ) this worked fine.
According to the Tcl/Tk documentation, .., cursor=... should use the routine
Tk_GetCursor. However this is not available when trying to call Tcl directly
by root.tk.call('Tk_GetCursor',...)

Sorry, no more ideas....
Kindly
MichaelP
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Starrett | last post by:
I am a just a dabbler in programming, but I'd like to make some simple cross-platform tools for generating webpages, as well as for text munging. One thing I need is a Mac OS 9/Windows GUI...
1
by: snx7s | last post by:
Hi, using Tkinter, on a Text widget i would like to place the cursor to a given position like the icursor() method of the Entry widget. Is it possible do that, if it is how please ? Thank You.
5
by: Andrew | last post by:
Hi I was wondering if there is anyway in Tkinter to create GUIs using Graphics, like windows media player or other tools like that basically so the interface wouldn't be your standard interface ...
3
by: Harlin Seritt | last post by:
I've created a ghetto-ized ComboBox that should work nicely for Tkinter (unfortunately no dropdown capabilities yet). I've found why it's such a pain in the @ss to create one. You have to...
2
by: Grooooops | last post by:
I've been hacking around this for a few days and have gotten close to what I want... but not quite... The TKinter Docs provide this example: # configure text tag text.tag_config("a",...
1
by: gregarican | last post by:
Checking a couple of examples I tried changing the Tkinter mouse cursor to indicate a busy state while my app is pushing/pulling xmlrpc data. It doesn't seem to make a difference as I don't notice...
4
by: jmdeschamps | last post by:
why is the button sunken when called through a bind method, and not with the command attribute? Thank you! ## Cut'nPaste example from Tkinter import * import tkMessageBox class...
5
by: Mudcat | last post by:
I was trying to design a widget that I could drag and drop anywhere in a frame and then resize by pulling at the edges with the mouse. I have fiddled with several different approaches and came...
4
by: skanemupp | last post by:
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.