def __init__(self, tabBar=None, **kwargs): self.tab_children = [] # TODO: can self.children be used instead? self.deck = DeckPanel(StyleName="gwt-TabPanelBottom") if tabBar is None: self.tabBar = TabBar() else: self.tabBar = tabBar self.tabListeners = [] # this is awkward: VerticalPanel is the composite, # so we get the element here, and pass it in to VerticalPanel. element = None if kwargs.has_key('Element'): element = kwargs.pop('Element') panel = VerticalPanel(Element=element) panel.add(self.tabBar) panel.add(self.deck) panel.setCellHeight(self.deck, "100%") self.tabBar.setWidth("100%") self.tabBar.addTabListener(self) if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-TabPanel" Composite.__init__(self, panel, **kwargs)
def __init__(self, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-TabBar" # this is awkward: HorizontalPanel is the composite, # so we either the element here, and pass it in to HorizontalPanel. element = None if kwargs.has_key('Element'): element = kwargs.pop('Element') self.panel = HorizontalPanel(Element=element) self.selectedTab = None self.tabListeners = [] self.panel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM) first = HTML(" ", True) rest = HTML(" ", True) first.setStyleName("gwt-TabBarFirst") rest.setStyleName("gwt-TabBarRest") first.setHeight("100%") rest.setHeight("100%") self.panel.add(first) self.panel.add(rest) first.setHeight("100%") self.panel.setCellHeight(first, "100%") self.panel.setCellWidth(rest, "100%") Composite.__init__(self, self.panel, **kwargs) self.sinkEvents(Event.ONCLICK)
def __init__(self, headerText, isOpen=False, **kwargs): self.handlers = [] self.content = None # this is awkward: VerticalPanel is the composite, # so we get the element here, and pass it in to VerticalPanel. element = None if kwargs.has_key('Element'): element = kwargs.pop('Element') self.mainPanel = VerticalPanel(Element=element) self.header = ClickableHeader(self) self.contentWrapper = SimplePanel() self.mainPanel.add(self.header) self.mainPanel.add(self.contentWrapper) DOM.setStyleAttribute(self.contentWrapper.getElement(), "padding", "0px"); DOM.setStyleAttribute(self.contentWrapper.getElement(), "overflow", "hidden"); self.isOpen = isOpen self.headerObj = DefaultHeader(headerText, self) self.setHeader(self.headerObj) if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-DisclosurePanel" Composite.__init__(self, self.mainPanel, **kwargs) self.setContentDisplay()
def __init__(self, tabBar=None, **kwargs): self.tab_children = [] # TODO: can self.children be used instead? self.deck = DeckPanel(StyleName="gwt-TabPanelBottom") if tabBar is None: self.tabBar = TabBar() else: self.tabBar = tabBar self.tabListeners = [] # this is awkward: VerticalPanel is the composite, # so we get the element here, and pass it in to VerticalPanel. element = None if kwargs.has_key('Element'): element = kwargs.pop('Element') panel = VerticalPanel(Element=element) panel.add(self.tabBar) panel.add(self.deck) panel.setCellHeight(self.deck, "100%") self.tabBar.setWidth("100%") self.tabBar.addTabListener(self) if not kwargs.has_key('StyleName'): kwargs['StyleName'] = "gwt-TabPanel" Composite.__init__(self, panel, **kwargs)
def final(self): Curr_count = None if self.counter: Curr_count = self.count_cdfs Curr_como = self.comon_cdfs Curr_convo = self.convo_cdfs Curr_act = self.actual_cdfs comp = Composite(self.folder_name, self.segment, Curr_act, Curr_como, Curr_convo, Curr_count) comp.save()
def __init__(self, *args, **kwargs): self.handlers = [] self.content = None # this is awkward: VerticalPanel is the composite, # so we get the element here, and pass it in to VerticalPanel. element = kwargs.pop('Element', None) # process the passed arguments headerText = headerWidget = None isOpen = False if len(args) == 1: header = args[0] if len(args) == 2: header, isOpen = args[:2] # apparently "basestring" is not understood if isinstance(header, str): headerText = header else: headerWidget = header isOpen = kwargs.pop('isOpen', isOpen) headerText = kwargs.pop('header', headerText) headerWidget = kwargs.pop('header', headerWidget) # TODO: add ImageBundle # images = kwargs.pop('images', None) # If both headerText and headerWidget are arguments, headerText will # be used to preserve API compatibility. headerContent = headerWidget if headerText is not None or headerContent is None: if headerText is None: headerText = "" headerContent = DefaultHeader(headerText) self.mainPanel = VerticalPanel(Element=element) self._init_header(headerContent) self.contentWrapper = SimplePanel() self.mainPanel.add(self.header) self.mainPanel.add(self.contentWrapper) DOM.setStyleAttribute(self.contentWrapper.getElement(), "padding", "0px"); DOM.setStyleAttribute(self.contentWrapper.getElement(), "overflow", "hidden"); if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-DisclosurePanel" Composite.__init__(self, self.mainPanel, **kwargs) # Must call setOpen after creating the initializing the object self.isOpen = None self.setOpen(isOpen) self.setContentDisplay()
class main: minhaPasta = Composite("Minha Pasta/") meuText1 = ArquivoTexto("Text 1.txt") meuText2 = ArquivoTexto("Text 2.txt") minhaPasta.__addArquivo__(meuText1) minhaPasta.__addArquivo__(meuText2) minhaPasta.__printNomeArquivo__()
def __init__(self, p, child, cDelegate, kDelegate) : Composite.__init__(self) self.clickDelegate = cDelegate self.keyDelegate = kDelegate self.focusablePanel = SimplePanel(Focus.createFocusable()) self.focusablePanel.setWidget(child) wrapperWidget = p.createTabTextWrapper() if wrapperWidget is None: self.initWidget(self.focusablePanel) else : wrapperWidget.setWidget(self.focusablePanel) self.initWidget(wrapperWidget) if hasattr(child, "addKeyboardListener"): child.addKeyboardListener(kDelegate) self.sinkEvents(Event.ONCLICK | Event.ONKEYDOWN)
def __init__(self, format="%d-%m-%Y"): self.format = format self.tbox = TextBox() self.tbox.setVisibleLength(10) # assume valid sep is - / . or nothing if format.find("-") >= 0: self.sep = "-" elif format.find("/") >= 0: self.sep = "/" elif format.find(".") >= 0: self.sep = "." else: self.sep = "" # self.sep = format[2] # is this too presumptious? self.calendar = Calendar() self.img = Image(self.icon_img) self.img.addStyleName(self.icon_style) self.calendarLink = HyperlinkImage(self.img, targetHistoryToken=History.getToken()) self.todayLink = Hyperlink(self.today_text, targetHistoryToken=History.getToken()) self.todayLink.addStyleName(self.today_style) # # lay it out # hp = HorizontalPanel() hp.setSpacing(2) vp = VerticalPanel() hp.add(self.tbox) vp.add(self.calendarLink) vp.add(self.todayLink) # vp.add(self.calendar) hp.add(vp) Composite.__init__(self) self.initWidget(hp) # # done with layout, so now set up some listeners # self.tbox.addFocusListener(self) # hook to onLostFocus self.calendar.addSelectedDateListener(getattr(self, "onDateSelected")) self.todayLink.addClickListener(getattr(self, "onTodayClicked")) self.calendarLink.addClickListener(getattr(self, "onShowCalendar"))
def __init__(self,format='%d-%m-%Y'): self.format = format self.tbox = TextBox() self.tbox.setVisibleLength(10) # assume valid sep is - / . or nothing if format.find('-') >= 0: self.sep = '-' elif format.find('/') >= 0: self.sep = '/' elif format.find('.') >= 0: self.sep = '.' else: self.sep = '' # self.sep = format[2] # is this too presumptious? self.calendar = Calendar() img = Image("icon_calendar.gif") img.addStyleName("calendar-img") self.calendarLink = HyperlinkImage(img) self.todayLink = Hyperlink('Today') self.todayLink.addStyleName("calendar-today-link") # # lay it out # hp = HorizontalPanel() hp.setSpacing(2) vp = VerticalPanel() hp.add(self.tbox) vp.add(self.calendarLink) vp.add(self.todayLink) #vp.add(self.calendar) hp.add(vp) Composite.__init__(self) self.initWidget(hp) # # done with layout, so now set up some listeners # self.tbox.addFocusListener(self) # hook to onLostFocus self.calendar.addSelectedDateListener(getattr(self,"onDateSelected")) self.todayLink.addClickListener(getattr(self,"onTodayClicked")) self.calendarLink.addClickListener(getattr(self,"onShowCalendar"))
def __init__(self, format='%d-%m-%Y'): self.format = format self.tbox = TextBox() self.tbox.setVisibleLength(10) # assume valid sep is - / . or nothing if format.find('-') >= 0: self.sep = '-' elif format.find('/') >= 0: self.sep = '/' elif format.find('.') >= 0: self.sep = '.' else: self.sep = '' # self.sep = format[2] # is this too presumptious? self.calendar = Calendar() self.img = Image(self.icon_img) self.img.addStyleName(self.icon_style) self.calendarLink = HyperlinkImage(self.img) self.todayLink = Hyperlink(today_text) self.todayLink.addStyleName(today_style) # # lay it out # hp = HorizontalPanel() hp.setSpacing(2) vp = VerticalPanel() hp.add(self.tbox) vp.add(self.calendarLink) vp.add(self.todayLink) #vp.add(self.calendar) hp.add(vp) Composite.__init__(self) self.initWidget(hp) # # done with layout, so now set up some listeners # self.tbox.addFocusListener(self) # hook to onLostFocus self.calendar.addSelectedDateListener(getattr(self, "onDateSelected")) self.todayLink.addClickListener(getattr(self, "onTodayClicked")) self.calendarLink.addClickListener(getattr(self, "onShowCalendar"))
self.tmin = tmin self.t = t self.p = p self.icon = icon api_key = "DARK_SKY_API_KEY" lat = 47.34638 lng = 0.45873 MAX_WIDTH = 640 MAX_HEIGHT = 384 wait = 1800 #ref_icons = dict(['clear',0],['clear-day',1],['clear-night',2],['cloudy',3],['fog',4],['hail',5],['NA',6],['partly-cloudy-day',7],['partly-cloudy-night',8],['rain',9],['sleet',10],['snow',11],['thunderstorm',12],['tornado',13],['wind',14]) screen = Composite(False) hour = dict() hour[4] = HourSet(0,0,0,0,'clear') hour[8] = HourSet(0,0,0,0,'clear') hour[12] = HourSet(0,0,0,0,'clear') paris = timezone('Europe/Paris') fmt = '%d/%m/%Y\n%H:%M' now = datetime.now(paris) fstLine = "Last update :\n" title = now.strftime(fmt) screen.AddText(fstLine+title,10,0,40,'title') text4 = "Now" screen.AddText(text4,340,0,20,'tup'+str(4),1)
if component1.is_composite(): component1.add(component2) print(f"RESULT: {component1.operation()}", end="") if __name__ == "__main__": # This way the client code can support the simple leaf components... print("Start") simple = Leaf() print("Client: I've got a simple component:") client_code(simple) print("\n") # ...as well as the complex composites. tree = Composite() branch1 = Composite() branch1.add(Leaf()) branch1.add(Leaf()) branch2 = Composite() branch2.add(Leaf()) tree.add(branch1) tree.add(branch2) print("Client: Now I've got a composite tree:") client_code(tree) print("\n")
from Composite import Composite from Operand import Operand from Add import Add from Multiply import Multiply #(10 + 25) * 4 + 52 * (3 + 6) expression = Composite(0) first_brackets = Add(Operand(10), Operand(25)) mul = Multiply(first_brackets, Operand(4)) second_brackets = Add(Operand(3), Operand(6)) mul2 = Multiply(second_brackets, Operand(52)) add = Add(mul, mul2) expression.add(add) print(expression.operation())
def composite(components, connections): from Composite import Composite return Composite(components, connections)
def client_code(component: Component): print(f"RESULT: {component.operation()}", end = "") def client_code2(composite: Component, component: Component): if composite.is_composite(): composite.add(component) print(f"RESULT: {component.operation()}", end = "") if __name__ == "__main__": simple = Leaf() print("Client: I've got a simple component:") client_code(simple) print("\n") tree = Composite() left_branch = Composite() left_branch.add(Leaf()) left_branch.add(Leaf()) right_branch = Composite() right_branch.add(Leaf()) tree.add(left_branch) tree.add(right_branch) print("Client: Now I've got a composite tree:") client_code(tree) print("\n") print("Client: I don't need to check the components classes even when managing the tree:") client_code2(tree, simple)