|
62 | 62 | if not config.pygameWelcomeMessage: |
63 | 63 | sys.stdout = open(os.devnull, "w") |
64 | 64 | import sb3Unpacker |
| 65 | +import downloader |
65 | 66 | from sb3Unpacker import * |
66 | 67 | import shutil |
67 | 68 | import scratch |
|
81 | 82 | if not config.enableDebugMessages: |
82 | 83 | sys.stderr = open(os.devnull, "w") |
83 | 84 |
|
| 85 | + |
| 86 | +# Define a dialog class for screen resolution |
| 87 | +class SizeDialog(tkinter.simpledialog.Dialog): |
| 88 | + def __init__(self, parent, title): |
| 89 | + super().__init__(parent, title) |
| 90 | + |
| 91 | + def body(self, master): |
| 92 | + tk.Label(master, text=widthPrompt).grid(row=0) |
| 93 | + tk.Label(master, text=heightPrompt).grid(row=1) |
| 94 | + |
| 95 | + self.width = tk.Entry(master) |
| 96 | + self.height = tk.Entry(master) |
| 97 | + |
| 98 | + self.width.grid(row=0, column=1) |
| 99 | + self.height.grid(row=1, column=1) |
| 100 | + |
| 101 | + return self.width |
| 102 | + |
| 103 | + def okPressed(self): |
| 104 | + self.setWidth = self.width.get() |
| 105 | + self.setHeight = self.height.get() |
| 106 | + self.destroy() |
| 107 | + |
| 108 | + def cancelPressed(self): |
| 109 | + self.destroy() |
| 110 | + |
| 111 | + def buttonbox(self): |
| 112 | + self.okButton = tk.Button(self, text=okText, width=5, command=self.okPressed) |
| 113 | + self.okButton.pack(side="left") |
| 114 | + cancelButton = tk.Button(self, text=cancelText, width=5, command=self.cancelPressed) |
| 115 | + cancelButton.pack(side="right") |
| 116 | + self.bind("<Return>", lambda event: self.okPressed()) |
| 117 | + self.bind("<Escape>", lambda event: self.cancelPressed()) |
| 118 | + |
| 119 | + |
84 | 120 | # Start tkinter for showing some popups, and hide main window |
85 | 121 | mainWindow = tk.Tk() |
86 | 122 | mainWindow.withdraw() |
|
90 | 126 | setProject = sys.argv[1] |
91 | 127 | else: |
92 | 128 | if config.testMode: |
93 | | - setProject = config.projectFileName |
| 129 | + if not config.projectFileName.endswith(".sb3"): |
| 130 | + if "http" not in config.projectFileName\ |
| 131 | + or "https" not in config.projectFileName: |
| 132 | + setProject = downloader.downloadByID(config.projectFileName, "./download") |
| 133 | + else: |
| 134 | + setProject = downloader.downloadByURL(config.projectFileName, "./download") |
| 135 | + else: |
| 136 | + setProject = config.projectFileName |
94 | 137 | else: |
95 | 138 | fileTypes = [(_("sb3-desc"), ".sb3"), (_("all-files-desc"), ".*")] |
96 | 139 | setProject = filedialog.askopenfilename(parent=mainWindow, |
|
165 | 208 | redrawMessage = _("redraw-message") |
166 | 209 |
|
167 | 210 |
|
168 | | -# Define a dialog class for screen resolution |
169 | | -class SizeDialog(tkinter.simpledialog.Dialog): |
170 | | - def __init__(self, parent, title): |
171 | | - super().__init__(parent, title) |
172 | | - |
173 | | - def body(self, master): |
174 | | - tk.Label(master, text=widthPrompt).grid(row=0) |
175 | | - tk.Label(master, text=heightPrompt).grid(row=1) |
176 | | - |
177 | | - self.width = tk.Entry(master) |
178 | | - self.height = tk.Entry(master) |
179 | | - |
180 | | - self.width.grid(row=0, column=1) |
181 | | - self.height.grid(row=1, column=1) |
182 | | - |
183 | | - return self.width |
184 | | - |
185 | | - def okPressed(self): |
186 | | - self.setWidth = self.width.get() |
187 | | - self.setHeight = self.height.get() |
188 | | - self.destroy() |
189 | | - |
190 | | - def cancelPressed(self): |
191 | | - self.destroy() |
192 | | - |
193 | | - def buttonbox(self): |
194 | | - self.okButton = tk.Button(self, text=okText, width=5, command=self.okPressed) |
195 | | - self.okButton.pack(side="left") |
196 | | - cancelButton = tk.Button(self, text=cancelText, width=5, command=self.cancelPressed) |
197 | | - cancelButton.pack(side="right") |
198 | | - self.bind("<Return>", lambda event: self.okPressed()) |
199 | | - self.bind("<Escape>", lambda event: self.cancelPressed()) |
200 | | - |
201 | | - |
202 | 211 | # Start project |
203 | 212 | toExecute = [] |
204 | 213 | eventHandlers = [] |
|
0 commit comments