def main(self): self.root_win = tk.Tk() self.root_win.withdraw() try: #Get the default user and configuration prefs = UserPrefs.UserPrefs() #show the dialog box if this is the first time logging_enabled = False consent_refused = False startup_cancelled = False view_order = 0 dwell_times = [] max_scroll_values = [] user_view_order = [] if not prefs.have_killswitch: if not prefs.have_consent: handler = FirstTimeHandler(Config.consent_filename, Config.info_logo_filename, Config.pictogram_filenames) (got_consent, user_closed_window, view_order, dwell_times, max_scroll_values, user_view_order) = handler.get_consent() if got_consent: prefs.set_have_consent() else: consent_refused = True if user_closed_window: startup_cancelled = True elif not prefs.shown_pictograms: picto_viewer = Pictoviewer(tk.Toplevel(), Config.info_logo_filename, Config.pictogram_filenames) picto_viewer.show() picto_viewer.destroy() dwell_times = picto_viewer.dwell_times max_scroll_values = picto_viewer.max_scroll_values user_view_order = picto_viewer.user_view_order if prefs.have_consent and not startup_cancelled: splash = SplashScreen.SplashScreen(tk.Toplevel(), prefs) (startup_cancelled, logging_enabled) = splash.show() if not startup_cancelled: if consent_refused: tkMessageBox.showwarning( "Logging disabled", "You did not give your consent. Your usage data will NOT be reported until consent is given." ) launcher = Launcher.Launcher(prefs, view_order, dwell_times, max_scroll_values, user_view_order, self._done_callback) launcher.spawn(logging_enabled) # Enter root window's mainloop to handle updates while the GIMP is running # If we don't do this, then things in Window can hang for a little while self.root_win.after(1000, self._done_check) self.root_win.mainloop() if self.result: # App launched and quit successfully if logging_enabled: print "Uploading collected data..." uploader = Uploader.Uploader(prefs) uploader.upload() print "Finished uploading." # Check for participation after quitting if not prefs.have_killswitch: participate = Participation.Participation( tk.Toplevel(), prefs) participate.check_for_participation() except Exception, e: tkMessageBox.showerror("ingimp Error", "ingimp Error: " + str(e))
space1 = tk.Label(window, text=' ') ok_button = tk.Button(window, command=self._handle_ok, text="OK", padx=40) logo.grid(row=0, column=0, rowspan=2) version_label.grid(row=2, column=0) user_label.grid(row=3, column=0) support_label.grid(row=4, column=0) space1.grid(row=5, column=0) ok_button.grid(row=6, column=0) ok_button.focus_set() self.window.bind("<Return>", self._handle_ok) def show(self): Utils.center_window(self.window) self.window.focus_set() self.window.mainloop() self.window.destroy() def _handle_ok(self, *args): self.window.withdraw() self.window.quit() if __name__ == '__main__': prefs = UserPrefs.UserPrefs() about = About(tk.Tk(), prefs) about.show()
def create_screen(): macx11screen = MacX11Screen(tk.Tk(), UserPrefs.UserPrefs()) return macx11screen
def check_for_participation(self): participation_url = self.prefs.get(UserPrefs.PARTICIPATION_URL) if participation_url: url_to_open = Utils.get_redirect_url(participation_url) if url_to_open: url_to_open = url_to_open + '?' + urllib.urlencode( [('id', self.prefs.user_id), ('version', Config.version)]) try: f = urllib2.urlopen(url_to_open) proceed = f.readline().strip() if (proceed == 'KILL'): self.prefs.set_have_killswitch() message_text = f.readline().strip() tkMessageBox.showinfo("End of Study", message_text) else: proceed = (proceed == 'YES') if proceed: self.message_text = f.readline().strip() self.interaction_url = f.readline().strip() f.close() if proceed: if self.message_text and self.interaction_url: self._show_dialog() except Exception, e: pass if __name__ == '__main__': participate = Participation(tk.Tk(), UserPrefs.UserPrefs()) participate.check_for_participation()
find_label = tk.Label(self.window, text=self.find_text) find_label.pack() help_label = tk.Label(self.window, text=self.help_text) help_label.pack() box = tk.Frame(self.window) web_button = tk.Button(box, text="Go to X11 Apple Support Page", width=30, command=self._handle_web, default=tk.ACTIVE) web_button.pack() quit_button = tk.Button(box, text="Quit", width=10, command=self._handle_quit) quit_button.pack() box.pack() self.window.bind("<Return>", self._handle_web) self.window.bind("<Escape>", self._handle_quit) def _handle_web(self, *args): webbrowser.open_new(self.x11_support_url) self._handle_quit() def _handle_quit(self, *args): self.window.quit() def _show_dialog(self): self._build_UI() Utils.center_window(self.window) self.window.mainloop() self.window.destroy() def show_dialog(self): self._show_dialog() if __name__ == '__main__': macx11screen = MacX11Screen(tk.Tk(), UserPrefs.UserPrefs()) macx11screen.show_dialog()