def create_unit_menu(master, command, variable=None, **options): optmenu = MyOptionMenu(master, unit_names, command=command, variable=variable) optmenu.configure(options) return optmenu
def build_dlg(self): top = self.top format_frame = Frame(top) format_frame.pack(side = TOP, expand = 1, fill = X, padx = 4, pady = 4) format_label = Label(format_frame, text = _("Paper format:")) format_label.pack(side = LEFT, expand = 1, fill = X) format_names = map(lambda t: t[0], PapersizesList) format_names.append(USER_SPECIFIC) self.var_format_name = StringVar(top) format_menu = MyOptionMenu(format_frame, format_names, variable = self.var_format_name, command = self.choose_format) format_menu.configure(width = max(map(len, format_names))) format_menu.pack(side = RIGHT, expand = 1, fill = X) orientation_frame = Frame(top) orientation_frame.pack(side = TOP, expand = 1, fill = X) self.var_orientation = IntVar(top) radio = UpdatedRadiobutton(orientation_frame, text = _("Portrait"), variable = self.var_orientation, value = Portrait, command = self.choose_orientation) radio.pack(side = LEFT, expand = 1, fill = X) radio = UpdatedRadiobutton(orientation_frame, text = _("Landscape"), variable = self.var_orientation, value = Landscape, command = self.choose_orientation) radio.pack(side = RIGHT, expand = 1, fill = X) size_frame = Frame(top) size_frame.pack(side = TOP, fill = X, expand = 1, padx = 4, pady = 4) var_width_number = DoubleVar(top) var_height_number = DoubleVar(top) var_width_unit = StringVar(top) var_height_unit = StringVar(top) unit = config.preferences.default_unit self.var_width = LengthVar(10, unit, var_width_number, var_width_unit) self.var_height = LengthVar(10, unit,var_height_number,var_height_unit) label = Label(size_frame, text = _("Page size:")) label.pack(side = TOP, anchor = W) label = Label(size_frame, text = _("Width")) label.pack(side = LEFT, anchor = E) self.widthentry = MyEntry(size_frame, textvariable = var_width_number, command = self.var_width.UpdateNumber, width = 6) self.widthentry.pack(side = LEFT, expand = 1, fill = X, anchor = E) label = Label(size_frame, text = _("Height")) label.pack(side = LEFT, anchor = E) self.heightentry = MyEntry(size_frame, textvariable =var_height_number, command = self.var_height.UpdateNumber, width = 6) self.heightentry.pack(side = LEFT, expand = 1, fill = X, anchor = E) def CallBoth(arg, x = self.var_width, y = self.var_height): x.UpdateUnit(arg) y.UpdateUnit(arg) optmenu = create_unit_menu(size_frame, CallBoth, variable = var_width_unit, indicatoron = 0, width = 3) optmenu.pack(side = LEFT, expand = 1, fill = X, anchor = W) button_frame = Frame(top) button_frame.pack(side = BOTTOM, fill = BOTH, expand = 1, padx = 4, pady = 4) button = UpdatedButton(button_frame, text = _("Apply"), command = self.apply_settings) button.pack(side = LEFT, expand = 1) button = UpdatedButton(button_frame, text = _("Close"), command = self.close_dlg) button.pack(side = RIGHT, expand = 1)
def create_unit_menu(master, command, variable = None, **options): optmenu = MyOptionMenu(master, unit_names, command = command, variable = variable) optmenu.configure(options) return optmenu