473,320 Members | 2,146 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,320 software developers and data experts.

How CAN i draw the symbol "om" in python

I am attaching the image of the symbol please help... its urgent....please reply
This is the url of wher u can see the symbol... its an assignment....
[url="http://www.yogaelements.com/blog/wp-content/uploads/2008/02/om4.jpg"]

Need not be exact copy

i have also attached the image
Attached Images
File Type: jpg om4.jpg (13.6 KB, 4884 views)
Feb 14 '10 #1
4 5346
bvdet
2,851 Expert Mod 2GB
You have posted a very vague question without showing any effort to solve the problem for yourself. I can give you an answer, but I won't write the code for you.

Create a Tkinter canvas.
Draw a polygon or a series polygons with fill

I attached an example of a canvas with a filled polygon.
Attached Images
File Type: jpg Tkinter_canvas_polygon_sm.jpg (13.2 KB, 1271 views)
Feb 14 '10 #2
please help me someone
Mar 1 '10 #3
bvdet
2,851 Expert Mod 2GB
abhishek07,

I would suggest laying out a grid, say 200x200, over the symbol and record Cartesian points at the vertices and along arcs to approximate the symbol. After that, you can create the filled polygons on a Tkinter canvas. Here's a basic example of creating a Tkinter canvas with filled polygons.
Expand|Select|Wrap|Line Numbers
  1. import random
  2. from Tkinter import *
  3.  
  4. class Pt(object):
  5.  
  6.     def __init__(self, x=0.0, y=0.0):
  7.         self.x = float(x)
  8.         self.y = float(y)
  9.  
  10.     def __add__(self, other):
  11.         return Pt(self.x+other.x, self.y+other.y)
  12.  
  13.     def __sub__(self, other):
  14.         return Pt(self.x-other.x, self.y-other.y)
  15.  
  16.     def __mul__(self, f):
  17.         return Pt(self.x*f, self.y*f)
  18.  
  19.     def __div__(self, f):
  20.         return Pt(self.x/f, self.y/f)
  21.  
  22.     def ray(self, limit):
  23.         return self, Pt(limit, self.y)
  24.  
  25.     def __iter__(self):
  26.         for a in [self.x, self.y]:
  27.             yield a
  28.  
  29.     def __str__(self):
  30.         return 'Pt(%0.4f, %0.4f)' % (self.x,self.y)
  31.  
  32.     def __repr__(self):
  33.         return 'Pt(%0.4f, %0.4f)' % (self.x,self.y)
  34.  
  35. if __name__ == '__main__':
  36.     limit = 400    
  37.     pt1 = Pt(random.choice(range(0,limit)), random.choice(range(0,limit)))
  38.     polygon = [Pt(280,380),
  39.                Pt(360,20),
  40.                Pt(100,34),
  41.                Pt(30,5),
  42.                Pt(19,240)]
  43.  
  44.     root = Tk()
  45.     w = Canvas(root, width=limit+10, height=limit+10)
  46.     w.create_rectangle(0,0,limit+10,limit+10,fill="#444444444")
  47.     expandPts = []
  48.     for pt in polygon:
  49.         expandPts.append(pt.x)
  50.         expandPts.append(pt.y)
  51.     # draw closed polygon
  52.     polyID = w.create_polygon(*expandPts)
  53.     w.itemconfig(polyID, fill="#fff000000",
  54.                  activefill="#000000fff",
  55.                  outline="#000000000",
  56.                  width=1)
  57.  
  58.     # draw ray from random point
  59.     w.create_line(pt1.x, pt1.y,
  60.                   pt1.ray(limit+10)[1].x,
  61.                   pt1.ray(limit+10)[1].y,
  62.                   fill="#ff0",width=2,
  63.                   activefill='#0f0')
  64.     # create a blip
  65.     w.create_line(pt1.x-4, pt1.y-4,
  66.                   pt1.x+4, pt1.y+4,
  67.                   fill="#ffffff",width=2)
  68.     w.create_line(pt1.x-4, pt1.y+4,
  69.                   pt1.x+4, pt1.y-4,
  70.                   fill="#ffffff",width=2)
  71.     w.pack()
  72.     root.mainloop()
Mar 1 '10 #4
bvdet
2,851 Expert Mod 2GB
What the heck - This version is interactive. Left click to select points on the canvas. Right click to draw a polygon and a horizontal ray beginning at a randomly selected point.
Expand|Select|Wrap|Line Numbers
  1. import random
  2. from Tkinter import *
  3.  
  4. class Pt(object):
  5.  
  6.     def __init__(self, x=0.0, y=0.0):
  7.         self.x = float(x)
  8.         self.y = float(y)
  9.  
  10.     def __add__(self, other):
  11.         return Pt(self.x+other.x, self.y+other.y)
  12.  
  13.     def __sub__(self, other):
  14.         return Pt(self.x-other.x, self.y-other.y)
  15.  
  16.     def __mul__(self, f):
  17.         return Pt(self.x*f, self.y*f)
  18.  
  19.     def __div__(self, f):
  20.         return Pt(self.x/f, self.y/f)
  21.  
  22.     def ray(self, limit):
  23.         return self, Pt(limit, self.y)
  24.  
  25.     def __iter__(self):
  26.         for a in [self.x, self.y]:
  27.             yield a
  28.  
  29.     def __str__(self):
  30.         return 'Pt(%0.4f, %0.4f)' % (self.x,self.y)
  31.  
  32.     def __repr__(self):
  33.         return 'Pt(%0.4f, %0.4f)' % (self.x,self.y)
  34.  
  35. if __name__ == '__main__':
  36.     limit = 400
  37.     ptList = []
  38.     def draw_blip(pt, size):
  39.         # create a blip
  40.         w.create_line(pt.x-size, pt.y-size,
  41.                       pt.x+size, pt.y+size,
  42.                       fill="#ffffff",width=2)
  43.         w.create_line(pt.x-size, pt.y+size,
  44.                       pt.x+size, pt.y-size,
  45.                       fill="#ffffff",width=2)
  46.  
  47.     def addPts(event):
  48.         ptList.append(Pt(event.x, event.y))
  49.         draw_blip(Pt(event.x, event.y), 1)
  50.     def finish(event):
  51.         event.widget.unbind("<ButtonRelease-1>")
  52.         event.widget.unbind("<ButtonRelease-3>")
  53.         pt1 = Pt(random.choice(range(0,limit)), random.choice(range(0,limit)))
  54.         expandPts = []
  55.         for pt in ptList:
  56.             expandPts.append(pt.x)
  57.             expandPts.append(pt.y)
  58.         # draw closed polygon
  59.         polyID = w.create_polygon(*expandPts)
  60.         w.itemconfig(polyID, fill="#fff000000",
  61.                      activefill="#000000fff",
  62.                      outline="#000000000",
  63.                      width=1)
  64.  
  65.         # draw ray from random point
  66.         w.create_line(pt1.x, pt1.y,
  67.                       pt1.ray(limit+10)[1].x,
  68.                       pt1.ray(limit+10)[1].y,
  69.                       fill="#ff0",width=2,
  70.                       activefill='#0f0')
  71.         draw_blip(pt1, 4)
  72.  
  73.     root = Tk()
  74.     w = Canvas(root, width=limit+10, height=limit+10)
  75.     w.bind("<ButtonRelease-1>", addPts)
  76.     w.bind("<ButtonRelease-3>", finish, "+")
  77.     w.create_rectangle(0,0,limit+10,limit+10,fill="#666")
  78.     w.pack()
  79.     root.mainloop()
Mar 1 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: carramba | last post by:
Hi! Sorry for the stupid subjekt, but coudn't get it better. I want that the user can chouse the skin of the site that I do by : ********************************************** <?...
3
by: Stephen Ferg | last post by:
I use the newsgroup mainly via my Web browser and Google. Over the last few days, when I click on a link to a thread, I've been frequently getting the message "Unable to find thread." Does...
7
by: Dominik Kaspar | last post by:
i'm used to java and its strict way of defining variables. so how is it possible to reach something like a class variable in python? with the following code i didn't have much succes... class...
3
by: Dan | last post by:
I am working on a python/zope web application and could really use some *expert* help on a short term basis. Is there an appropriate forum for trolling for Python Consultants? Here are a pair...
3
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause...
5
by: Lars Netzel | last post by:
Hey! I have tried...(in a datagrid) e.KeyDate.Return and e.KeyDate.TAB end e.KeyDate.Enter
3
by: Quick | last post by:
.Value is now .setattribute & .getattribute("name", "value") What took the place of .Click? I see .Click is still stated as a method of Forms. I have a reference "xForm" to the exact form I...
0
by: U S Contractors Offering Service A Non-profit | last post by:
" Visionary Dreams " " Leaving New york City leaving to go " GOD noes were i Don't "
1
by: =?Utf-8?B?VGFsYWxTYWxlZW0=?= | last post by:
i have facility in my website which sends an e-mail to the cleint's inbox..... i am getting a problem when ever i sends an e-mail.. i tried with Hotmail and Yahoo, e-mail goes to the "Junk Mail"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.