コード例 #1
0
    def __init__(self, place):
        """Constructor for temperature class.

		Parameter: place - the location to search.
		"""
        self.place = place

        self.label = tkinter.Label(text=':(',
                                   font=('Courier', '20'),
                                   fg='black',
                                   bg='grey',
                                   height=2,
                                   width=3)
        self.label.master.overrideredirect(True)
        self.label.master.wm_attributes("-topmost", True)
        self.label.master.geometry("+5+850")
        self.label.master.wm_attributes("-transparentcolor", "grey")
        self.label.bind("<Button-1>", self.click)
        self.label.bind("<Button-3>", self.right_click)
        self.label.bind("<B1-Motion>", self.drag)
        self.label.pack()

        self.popup_menu = tkinter.Menu(self.label.master)
        self.popup_menu.add_command(label="Switch Color",
                                    command=self.change_color)
        self.popup_menu.add_command(label="Change Location",
                                    command=self.get_location)
        self.popup_menu.add_command(label="Exit", command=self.destroy)
        self.balloon = Balloon(self.label.master)
コード例 #2
0
    def __init__(self,
                 master,
                 root,
                 iconsManager=None,
                 idleRedraw=True,
                 nodeHeight=15,
                 headerHeight=0,
                 treeWidth=160,
                 balloon=None,
                 **kw):

        Tree.__init__(self,
                      master,
                      root,
                      iconsManager=iconsManager,
                      idleRedraw=idleRedraw,
                      nodeHeight=nodeHeight,
                      headerHeight=headerHeight,
                      balloon=balloon,
                      **kw)

        self.objectToNode = {}  # key is object, values if Node instance
        self.objectToNode[root.object] = root

        self.nbCol = 0  # number of columns of buttons
        self.columns = []  # list of ColumnDescriptor instance
        self.balloon = Balloon(master)

        self.colLabIds = []

        self.colWidth = 17  # width of each column in pixels
        w = self.treeWidth = treeWidth  # width of the tree part of the widget
        self.newTreeWidth = 0  # used to widen tree whebn labels gets long
        self.prevX = 0
        self.prevY = 0

        # draw the divider between tree and buttons
        canvas = self.canvas

        id_ = canvas.create_line(w - 6, 0, w - 6, 1000, fill='grey75', width=3)
        self.dividerCanvasId = id_
        canvas.tag_bind(id_, "<Enter>", self.enterDivider_cb)
        canvas.tag_bind(id_, "<Leave>", self.leaveDivider_cb)
        canvas.tag_bind(id_, "<Button-1>", self.dividePress_cb)
        canvas.tag_bind(id_, "<ButtonRelease-1>", self.divideRelease_cb)
        #id_ = canvas.create_line( w+1, 0, w+1, 1000, fill='grey75')
        #self.dividerCanvasIds.append(id_)

        self.crosshairTk = None
        self.canvas.bind("<Leave>", self.leave_cb)
        self.circlesForOnOff = True
        self.lastHighligted = None
        self.minTreeWidth = 0  # width of buttons above tree
コード例 #3
0
    def __init__(self, *args, **kwargs):
        BaseInputPage.__init__(self, "Professor", *args, **kwargs)

        self.first_name_var = StringVar(self.input_widgets_frame)
        _, _, first_name_entry = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "First Name",
            "Entry",
            textvariable=self.first_name_var,
            f_pady=5,
            required=True)
        self.input_widget_descriptors.append(
            (first_name_entry, self.first_name_var, ""))

        self.middle_name_var = StringVar(self.input_widgets_frame)
        _, _, middle_name_entry = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Middle Name",
            "Entry",
            textvariable=self.middle_name_var,
            f_pady=5,
            required=False)
        self.input_widget_descriptors.append(
            (middle_name_entry, self.middle_name_var, ""))

        self.last_name_var = StringVar(self.input_widgets_frame)
        _, _, last_name_entry = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Last Name",
            "Entry",
            textvariable=self.last_name_var,
            f_pady=5,
            required=True)
        self.input_widget_descriptors.append(
            (last_name_entry, self.last_name_var, ""))

        self.depts_var = StringVar(self.input_widgets_frame)
        depts_frame, _, depts_entry = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Departments",
            "Entry",
            textvariable=self.depts_var,
            f_pady=5,
            required=True)
        self.input_widget_descriptors.append((depts_entry, self.depts_var, ""))

        Balloon(self).bind(
            depts_frame, """
				Enter a list of comma-seperated department codes that this\n
				professor can teach in. For example, physics, engineering,\n
				and math could look like \"PH,ENG,MA\" (spaces are optional).
			""".replace("\n\t", "").replace("\t", ""))
コード例 #4
0
class temperature:
    def __init__(self, place):
        """Constructor for temperature class.

		Parameter: place - the location to search.
		"""
        self.place = place

        self.label = tkinter.Label(text=':(',
                                   font=('Courier', '20'),
                                   fg='black',
                                   bg='grey',
                                   height=2,
                                   width=3)
        self.label.master.overrideredirect(True)
        self.label.master.wm_attributes("-topmost", True)
        self.label.master.geometry("+5+850")
        self.label.master.wm_attributes("-transparentcolor", "grey")
        self.label.bind("<Button-1>", self.click)
        self.label.bind("<Button-3>", self.right_click)
        self.label.bind("<B1-Motion>", self.drag)
        self.label.pack()

        self.popup_menu = tkinter.Menu(self.label.master)
        self.popup_menu.add_command(label="Switch Color",
                                    command=self.change_color)
        self.popup_menu.add_command(label="Change Location",
                                    command=self.get_location)
        self.popup_menu.add_command(label="Exit", command=self.destroy)
        self.balloon = Balloon(self.label.master)

    def update_temp(self):
        """Update the temperature every 10 minutes between 7 AM and 5 PM"""
        cur_hour = time.localtime()[3]
        if cur_hour > 6 and cur_hour < 18:
            try:
                self.observation = owm.weather_at_id(self.place)
            except (ParseResponseError, APICallError):
                ftemp = ':('
            else:
                w = self.observation.get_weather()
                temp = math.ceil(w.get_temperature('fahrenheit')['temp'])
                ftemp = f'{temp}' + u'\N{DEGREE SIGN}'
                self.balloon.unbind(self.label)
                self.balloon.bind(self.label, self.get_balloon_text(w))
            self.label.configure(text=ftemp)
        self.timer = self.label.after(600000, self.update_temp)

    def get_pointer_x(self):
        """Return the x-coordinate of the cursor position."""
        return self.label.master.winfo_pointerx()

    def get_pointer_y(self):
        """Return the y-coordinate of the cursor position."""
        return self.label.master.winfo_pointery()

    def update_position(self, x, y):
        """Update the position of the label.
		
		Parameters: x - x-coordinate to move to
			    y - y-coordinate to move to
		"""
        self.label.master.geometry(f'+{x}+{y}')

    def click(self, event):
        """On the left click event, saves the coordinates of the event."""
        self.offset_x = event.x
        self.offset_y = event.y

    def drag(self, event):
        """On the drag event, calculates and updates the labels position."""
        x = self.get_pointer_x() - self.offset_x
        y = self.get_pointer_y() - self.offset_y
        self.update_position(x, y)

    def right_click(self, event):
        """On right click, popup menu appears."""
        try:
            self.popup_menu.tk_popup(event.x_root, event.y_root, 0)
        finally:
            self.popup_menu.grab_release()

    def change_color(self):
        """Switches the color of the label between light and dark."""
        if self.label.cget('fg') == 'black':
            font = 'white'
            backing = 'lavender blush'
        else:
            font = 'black'
            backing = 'grey'
        self.label.config(fg=font, bg=backing)
        self.label.master.wm_attributes("-transparentcolor", backing)

    def get_location(self):
        """Get the location change input by user and update the temperature."""
        place_location = self.observation.get_location()
        self.change_loc = wcl.change_location(owm, place_location,
                                              self.get_pointer_x,
                                              self.get_pointer_y)
        place_location = self.change_loc.get_location()
        self.place = place_location.get_ID()
        self.label.after_cancel(self.timer)
        try:
            self.update_temp()
        except tkinter.TclError:
            pass

    def destroy(self):
        """Destroy any windows remaining open."""

        try:
            self.change_loc.destroy()
        except AttributeError:
            pass
        self.label.master.destroy()

    def get_balloon_text(self, w):
        """Get the weather text for the balloon.
		
		Parameters: w - a weather object"""
        last_update_time = dateutil.parser.parse(
            w.get_reference_time('iso')).astimezone(tz=None)
        rain = w.get_rain()
        snow = w.get_snow()
        wind = w.get_wind()['speed']
        balloon_string = f'Last updated {last_update_time.hour}:{last_update_time.minute}'
        if rain:
            balloon_string = ''.join([balloon_string, f'\nRain {rain}'])
        if snow:
            balloon_string = ''.join([balloon_string, f'\nSnow {snow}'])
        if wind:
            balloon_string = ''.join([balloon_string, f'\nWind Speed: {wind}'])
        return balloon_string
コード例 #5
0
ファイル: GRCF.py プロジェクト: latrop/GRCF
############################################################

rightPanel = Tk.Frame(master)
rightPanel.pack(side=Tk.RIGHT, expand=1)

# Variable to check if computation is needed after brtforce, dradient descent etc.
computationIsNeeded = Tk.IntVar()
computationIsNeeded.set(0)
computationIsNeeded.trace("w", lambda n, i, m, v=computationIsNeeded: runComputation())

##########################
#   general parameters   #
##########################

generalPanel = Tk.Frame(rightPanel)
generalBalloon = Balloon(generalPanel)
generalPanel.grid(column=0, row=1)

# Place checkbutton for correcting for inclination question
correctForInclination = Tk.IntVar()
correctForInclination.set(0)
correctForInclination.trace("w",lambda n, i, m, v=correctForInclination: some_parameter_changed("inclCorrect", v.get()))
correctForInclinationCB = Tk.Checkbutton(generalPanel,
                                         text="Correct for inclination?",
                                         variable=correctForInclination,
                                         state="disabled")

correctForInclinationText = """If this option is on, observed rotation curve will be corrected
for inclination computed from disc's q and z0/h."""
generalBalloon.bind(correctForInclinationCB, correctForInclinationText)
correctForInclinationCB.grid(column=0, row=0, columnspan=3)
コード例 #6
0
    def __init__(self, *args, **kwargs):
        BaseInputPage.__init__(self, "Restriction", *args, **kwargs)

        self.type_options = {
            t.pretty_print(): t.value
            for t in RestrictionType
        }
        type_options_list = list(self.type_options.keys())
        self.type_var = StringVar(self.input_widgets_frame)
        _, _, type_menu = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Restriction Type",
            "OptionMenu",
            self.type_var,
            *type_options_list,
            required=True)
        self.input_widget_descriptors.append(
            (type_menu, self.type_var, type_options_list[0]))

        self.single_group_var = StringVar(self.input_widgets_frame)
        single_group_frame, _, self.single_group_entry = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Single Group Course Codes",
            "Entry",
            f_pady=15,
            textvariable=self.single_group_var,
            required=True)
        self.input_widget_descriptors.append(
            (self.single_group_entry, self.single_group_var, ""))

        multiple_groups_frame, _, self.multiple_groups_text = BasePage.get_labeled_input_field(
            self.input_widgets_frame,
            "Multiple Groups Course Codes",
            "Text",
            f_expand=True,
            l_side="top",
            l_fill="x",
            i_side="top",
            i_fill="x",
            i_expand=True,
            width=40,
            height=8,
            wrap="none",
            required=True)
        self.input_widget_descriptors.append(
            (self.multiple_groups_text, None, ""))

        #text_yscrollbar = Scrollbar(multiple_groups_frame, orient="vertical")
        #self.multiple_groups_text["yscrollcommand"] = text_yscrollbar.set
        #text_yscrollbar.config(command=self.multiple_groups_text.yview)
        #text_yscrollbar.pack(side="right", fill="y")

        text_xscrollbar = Scrollbar(multiple_groups_frame, orient="horizontal")
        self.multiple_groups_text["xscrollcommand"] = text_xscrollbar.set
        text_xscrollbar.config(command=self.multiple_groups_text.xview)
        text_xscrollbar.pack(side="bottom", fill="x")

        Balloon(self).bind(
            single_group_frame, """
				Enter a list of comma-seperated course codes for courses that should\n
				not be taught at the same time and day, and please include a hyphen\n
				between the department code and the course number. For example, if\n
				MA101, MA104, PH101, and PH201 should not be ran in parallel, then input\n
				could look like \"MA-101,MA-104,PH-101,PH-201\" (spaces before or after\n
				each comma are optional).
			""".replace("\n\t", "").replace("\t", ""))

        Balloon(self).bind(
            multiple_groups_frame, """
				Enter a list of comma-seperated and new-line-seperated course codes for groups of courses\n
				that should not be taught at the same time and day, but the courses within a group can be\n
				taught in parallel, and please include a hyphen between the department code and the course\n
				number, and start each group on a new line. For example, if:PNL
				1.) MA101, MA201, and MA301 are allowed to run in parallelPNL
				2.) But none of those should run at the same time and day as MS301, MS302, MS303, or MS304,\n
				      even though each of those MS courses are allowed to run in parallelPNL
				3.) And neither of those two groups should run in parallel with ANY engineering coursePNL
				PNL
				Then input could look like:PNL
				MA-101,MA-201,MA-301PNL
				MS-301,MS-302,MS-303,MS-304PNL
				ER-*PNL
				PNL
				(Spaces before or after each comma are optional.)
			""".replace("\n\t", "").replace("\t", "").replace("PNL", "\n"))

        self.type_var.trace("w", self.update_widget_states)
コード例 #7
0
        "About",
        "DungeonGenerator for Pathfinder, by Chris Pack. \n \n Enter your party level and the number of rooms in Generate. \n Hover over monster tokens for monster info. \n Special thanks to Alisa Pack, James Switzer, and Pasha Wrangell. \n Based on an algorithm by Gary Gygax."
    )


top = Tk()
tehframe = Frame(top)
initialise(top)  #Pmw: hovertext widget starter
tehframe.pack(side=LEFT, fill=Y, expand=TRUE)
#save picture files to variables
stairs1 = PhotoImage(file='stairs1.gif')
monster1 = PhotoImage(file='monster1.gif')

settingsbox = levelselect(top, generatedungeon)
#show hover text on monsters, tooltips thanks to PythonMegaWidgets
balloon = Balloon(top)  #Pmw: declare the hovertext balloon

generatebutton = Button(tehframe, text="Generate", command=settingsbox.prompt)
generatebutton.pack(side=TOP)

aboutbutton = Button(tehframe, text="About", command=aboutbox)
aboutbutton.pack(side=TOP, fill=X, pady=3)

quitbutton = Button(tehframe, text="Quit", command=quit)
quitbutton.pack(side=TOP, fill=X)

mapscrollx = Scrollbar(top, orient=HORIZONTAL)
mapscrollx.pack(side=BOTTOM, fill=X)
mapscrolly = Scrollbar(top, orient=VERTICAL)
mapscrolly.pack(side=RIGHT, fill=Y)
コード例 #8
0
    global stop_run
    stop_run.set()


# Fill the Pokemon Frame
population_label = Label(pokemon_frame, text='Current Population', bg=BG_COLOR)
pokemon_canvas = Frame(pokemon_frame,
                       height=364,
                       width=364,
                       bg=FG_COLOR,
                       bd=2,
                       relief=RIDGE)
population_label.pack(side=TOP)
pokemon_canvas.pack(side=TOP)
pokemon_info = Balloon(pokemon_canvas)

# Fill the Menu Frame
generation_number_label = Label(menu_frame,
                                textvariable=generation_string,
                                bg=BG_COLOR,
                                relief=RIDGE)
generate_population_button = Button(menu_frame,
                                    text='Generate Random Population',
                                    bg=FG_COLOR,
                                    command=generate_population,
                                    state=NORMAL)
next_generation_button = Button(menu_frame,
                                text='Next Generation',
                                bg=FG_COLOR,
                                command=advance_generation,