473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "@testcurso r 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(kNullCu rsorData)
f.close()
t=Text(root,bg= "white",cursor= "@testcurso r white")
t.pack()
root.mainloop()


Jul 18 '05 #1
3 5904

"Gary Richardson" <ga***@fidalgo. net> schrieb im Newsbeitrag
news:vm******** ***@corp.supern ews.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 "@testcurso r 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.C UR". I also tried using the
full pathname ("@C:\windows\c ursors\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="w hite",cursor="@ CROSS_M.CUR").p ack()
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.C UR". 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='@f ile',.. ) 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('T k_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
1565
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 solution. I thought that Tkinter could provide this, but I'm having trouble getting the simple test script from Learning Python p.22 to work under Mac OS 9 (9.2.2, on a 400 MHz PowerBook firewire/2000, 192 MB ram). Starting with a clean install of...
1
6728
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
3688
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 any ideas, links to tutorials, or examples is appreciated Cheers
3
6688
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 re-create common methods and make sure they're mapped to the right component (inside this widget are frame, entry, listbox, and scrollbar widgets). I tried to look for ways I could inherit some methods from other widgets but couldn't think of how to do...
2
5075
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", foreground="blue", underline=1) text.tag_bind("a", "<Enter>", show_hand_cursor) text.tag_bind("a", "<Leave>", show_arrow_cursor) text.tag_bind("a", "<Button-1>", click) text.config(cursor="arrow")
1
3831
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 the cursor actually change in the span of the 3-5 second transaction. I tried changing the cursor of the root widget, the toplevel widget, etc. all to no avail. Is there something really basic I'm overlooking? Is it enough to just change the...
4
3184
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 Vue(object):
5
1970
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 across this behavior when using the combination of place() and configure(cursor = ...) This problem doesn't occur if you remove either one of these elements. It's a very basic design of a button wrapped in a sizer frame and is supposed to work like...
4
9132
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 the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something like canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. get the color of the image where i clicked.
0
8394
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.