Skip to content

Commit 9b56f24

Browse files
authored
Added size to the output window
Added size to the output window
1 parent 1372447 commit 9b56f24

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

ppython/ppython.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
def handle(text):
4+
def handle(text, height, width):
55
tab = " "
66
nl = "\n"
77
glob_set = "global width, height, mouseX, mouseY"
@@ -16,7 +16,9 @@ def handle(text):
1616
if (text.find(setup) != -1):
1717
text = ""+text+"\nsetup()"
1818
if (text.find(draw) != -1):
19-
text = ""+text+"\ndraw()"
19+
text = ""+text+"\ndraw()"
20+
21+
text = f"_p = ppp(root, {height}, {width}) \nwidth = _p.width \nheight = _p.height \n\n" + text
2022
with open("template.py","r") as f:
2123
z=f.read()
2224
z=z.replace("===||===",text)
@@ -32,5 +34,14 @@ def handle(text):
3234
# exec(f.read())
3335

3436
# print(sys.argv)
37+
38+
height = 500
39+
width = 500
40+
if len(sys.argv) == 4:
41+
height = sys.argv[2]
42+
width = sys.argv[3]
43+
elif len(sys.argv) == 3:
44+
height = sys.argv[2]
45+
3546
with open(sys.argv[1]) as f:
36-
handle(f.read())
47+
handle(f.read(), height, width)

ppython/template.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
from tkinter import *
44

55
class ppp:
6-
def __init__(self, root):
6+
def __init__(self, root, height, width):
77
self.Stroke_ = "black"
88
self.Fill_="black"
99
self.StrokeSize_ = 3
1010
self.sX = 500
1111
self.sY = 100
1212
self.mouseX = 0
1313
self.mouseY = 0
14-
self.canvas = Canvas(root, height=500, width=500, bg="white")
14+
self.height = height
15+
self.width = width
16+
self.canvas = Canvas(root, height=self.height, width=self.width, bg="white")
1517
self.canvas.grid(row=0, column=0)
16-
self.width = int(self.canvas.cget("width"))
17-
self.height = int(self.canvas.cget("height"))
18+
#self.width = int(self.canvas.cget("width"))
19+
#self.height = int(self.canvas.cget("height"))
1820
self.points = []
1921

2022
def line(self, x, y, x2, y2):
@@ -167,10 +169,6 @@ def text(string, x, y):
167169
root = Tk()
168170
root.title("processing python")
169171

170-
_p = ppp(root)
171-
width = _p.width
172-
height = _p.height
173-
174172
===||===
175173

176174
def motion(event):

0 commit comments

Comments
 (0)