Best Python code snippet using pyatom_python
PopupMenuCtrl.py
Source:PopupMenuCtrl.py
1from Components.Base.BaseCtrl import *2class PopupMenu(Base):3 def __init__(self, attrs):4 super().__init__(attrs)5 self.CmpType = 'PopupItem';6 self.tag = 'div';7 self.isJoin = ArrKeyRtrn(self.attrs, 'join_menu', False);8 self.joinGroup = ArrKeyRtrn(self.attrs, 'join_group', False);9 self.lastitem = None;10 self.text = '';11 self.text = ""12 self.styleArr = ["z-index: 10", "left: 136px", "top: 9px"]13 if 'style'in self.attrs:14 self.styleArr.extend([i for i in attrs['style'].split(";")])15 del self.attrs['style']16 if 'text' in self.attrs:17 del self.attrs['text']18 def show(self):19 eventsStr = " ".join(f'{k}="{v}"' for k, v in self.attrs.items() if k[:2] == "on")20 atr = " ".join(f'{k}="{v}"' for k, v in self.attrs.items() if not k[:2] == "on")21 self.print(f"""22<div class="popupMenu" name="{self.name}" cmptype="PopupMenu" title="" tabindex="0" cont="menu" id="d3ctrl{self.genName()}" {atr} {eventsStr} style="{';'.join(self.styleArr)}">23 <div class="item waittext">ÐодождиÑе...</div>24""")25 # ÐобавлÑеÑÑÑ Ð¿Ñи иниÑиализаÑии d3main.js d3theme.css26 # self.SetSysInfo.append("<scriptfile>Components/Edit/js/Edit.js</scriptfile>")27 # self.SetSysInfo.append("<cssfile>Components/Edit/css/Edit.css</cssfile>")28"""29<div class="popupMenu" name="pMENU" cmptype="PopupMenu" title="" tabindex="0" cont="menu" id="d3ctrl131635341869511"30 style="z-index: 10; left: 136px; top: 9px;">31 <div class="item waittext">ÐодождиÑе...</div>32 33 <div class="item active" cmptype="PopupItem" name="cmp6179562f0ce9b" title="" rootitem="true"34 caption="22222222222222222" id="d3ctrl161635341869511">35 <table style="width:100%" cmpparse="PopupItem" cont="item" onclick="alert(1)D3Api.PopupItemCtrl.clickItem(this);" onmouseover="D3Api.PopupItemCtrl.hoverItem(this);">36 <tbody>37 <tr>38 <td class="itemCaption"><img src="" cont="itemIcon" class="itemIcon"><span cont="itemCaption">22222222222222222</span>39 </td>40 <td class="caret"></td>41 </tr>42 </tbody>43 </table>44 </div>45 46 <div class="item " cmptype="PopupItem" name="cmp6179562f0d6b3" title="" rootitem="true" caption="11111111111111111" id="d3ctrl191635341869511">47 <table style="width:100%" cmpparse="PopupItem" cont="item" onclick="alert(1)D3Api.PopupItemCtrl.clickItem(this);" onmouseover="D3Api.PopupItemCtrl.hoverItem(this);">48 <tbody>49 <tr>50 <td class="itemCaption">51 <img src="" cont="itemIcon" class="itemIcon"><span cont="itemCaption">11111111111111111</span>52 </td>53 <td class="caret"></td>54 </tr>55 </tbody>56 </table>57 </div>58 59</div>60<div class="item separator ctrl_hidden" item_split="true" cmptype="PopupItem" id="d3ctrl691635342474373"></div>61<body style="height: 100%;" onresize="D3Api.resize(false);" oncontextmenu="return D3Api.onContextMenuBody(event);" onbeforeunload1="return 'Ðнимание.';">62 63 64<div class="popupMenu" name="pMENU" cmptype="PopupMenu" title="" tabindex="0" cont="menu" id="d3ctrl131635341690363"65 style="z-index: 10; display: block; left: 118px; top: 7px;">66 <div class="item waittext">ÐодождиÑе...</div>67 <div class="item active" cmptype="PopupItem" name="cmp6179557bdddc6" title="" rootitem="true" caption="1" id="d3ctrl161635341690363">68 69 <table style="width:100%" cmpparse="PopupItem" cont="item" onclick="alert(1)D3Api.PopupItemCtrl.clickItem(this);" onmouseover="D3Api.PopupItemCtrl.hoverItem(this);">70 <tbody>71 <tr>72 <td class="itemCaption"><img src="" cont="itemIcon" class="itemIcon"><span cont="itemCaption">1</span>73 </td>74 <td class="caret"></td>75 </tr>76 </tbody>77 </table>78 79 </div>80 <div class="popupGroupItem" cont="groupitem" name="additionalMainMenu" cmptype="PopupGroupItem" id="d3ctrl191635341690363"></div>81 <div class="item separator ctrl_hidden" item_split="true" cmptype="PopupItem" id="d3ctrl331635341690366"></div>82 <div class="popupGroupItem" cont="groupitem" name="system" cmptype="PopupGroupItem" separator="before" id="d3ctrl221635341690363"></div>83</div>84<div class="popupMenu" name="pMENU" cmptype="PopupMenu" title="" tabindex="0" cont="menu" id="d3ctrl131635341869511"85 style="z-index: 10; display: block; left: 136px; top: 9px;">86 <div class="item waittext">ÐодождиÑе...</div>87 88 <div class="item active" cmptype="PopupItem" name="cmp6179562f0ce9b" title="" rootitem="true"89 caption="22222222222222222" id="d3ctrl161635341869511">90 <table style="width:100%" cmpparse="PopupItem" cont="item" onclick="alert(1)D3Api.PopupItemCtrl.clickItem(this);" onmouseover="D3Api.PopupItemCtrl.hoverItem(this);">91 <tbody>92 <tr>93 <td class="itemCaption"><img src="" cont="itemIcon" class="itemIcon"><span cont="itemCaption">22222222222222222</span>94 </td>95 <td class="caret"></td>96 </tr>97 </tbody>98 </table>99 </div>100 101 <div class="item " cmptype="PopupItem" name="cmp6179562f0d6b3" title="" rootitem="true" caption="11111111111111111"102 id="d3ctrl191635341869511">103 <table style="width:100%" cmpparse="PopupItem" cont="item"104 onclick="alert(1)D3Api.PopupItemCtrl.clickItem(this);"105 onmouseover="D3Api.PopupItemCtrl.hoverItem(this);">106 <tbody>107 <tr>108 <td class="itemCaption"><img src="" cont="itemIcon" class="itemIcon"><span cont="itemCaption">11111111111111111</span>109 </td>110 <td class="caret"></td>111 </tr>112 </tbody>113 </table>114 </div>115 116 <div class="popupGroupItem" cont="groupitem" name="additionalMainMenu" cmptype="PopupGroupItem" id="d3ctrl221635341869511"></div>117 <div class="item separator ctrl_hidden" item_split="true" cmptype="PopupItem" id="d3ctrl361635341869513"></div>118 <div class="popupGroupItem" cont="groupitem" name="system" cmptype="PopupGroupItem" separator="before" id="d3ctrl251635341869511"></div>119</div>...
PopupItemCtrl.py
Source:PopupItemCtrl.py
1from Components.Base.BaseCtrl import *2class PopupItem(Base):3 def __init__(self, attrs):4 super().__init__(attrs)5 self.CmpType = 'PopupItem';6 if 'text' in self.attrs:7 self.tagCls = '</div></div><div class="popupGroupItem" cont="groupitem" name="additionalMainMenu" cmptype="PopupGroupItem"></div><div class="popupGroupItem" cont="groupitem" name="system" cmptype="PopupGroupItem" ></div>';8 else:9 self.tagCls = '''</div> <div class="popupGroupItem" cont="groupitem" name="additionalMainMenu" cmptype="PopupGroupItem"></div><div class="popupGroupItem" cont="groupitem" name="system" cmptype="PopupGroupItem" ></div>''';10 self.tag = 'div';11 self.text = ""12 self.onclick = ""13 if 'onclick' in self.attrs:14 self.onclick = self.attrs["onclick"]15 del self.attrs['onclick']16 self.onmouseover = ""17 if 'onmouseover' in self.attrs:18 self.onmouseover = self.attrs["onmouseover"]19 del self.attrs['onmouseover']20 self.caption = ""21 if 'caption' in self.attrs:22 self.caption = self.attrs["caption"]23 del self.attrs['caption']24 self.icon = ""25 self.placeholder = ""26 if 'placeholder' in self.attrs:27 self.placeholder = self.attrs["placeholder"]28 del self.attrs['placeholder']29 self.icon = ""30 #icon = "~CmpPopupMenu/Icons/generation" / >31 # std_icon="generation"32 if 'icon' in self.attrs:33 if '~Cmp' in self.attrs["icon"]:34 self.icon = f"/Components/PopupMenu/images/Icons/{self.attrs['icon'][4:]}.png"35 else:36 self.icon = self.attrs["icon"]37 del self.attrs['icon']38 if 'std_icon' in self.attrs:39 self.icon = f"/Components/PopupMenu/images/Icons/{self.attrs['std_icon']}.png"40 del self.attrs['std_icon']41 def show(self):42 eventsStr = " ".join(f'{k}="{v}"' for k, v in self.attrs.items() if k[:2] == "on")43 atr = " ".join(f'{k}="{v}"' for k, v in self.attrs.items() if not k[:2] == "on")44 subItems=""45 if 'text' in self.attrs: # ÐÑли еÑÑÑ Ñебенок46 subItems = '''<div class="popupMenu subItems" cont="menu" style="left: 171.141px; top: 0px; z-index: 10;">'''47 split = ""48 if self.caption == "-":49 self.print(f"""<div class="item separator " cmptype="PopupItem" name="{self.name}" title="" rootitem="true" item_split="true" id="d3ctrl{self.genName()}" {eventsStr} {atr}>{subItems}""")50 else:51 self.print(f"""52 <div class="item " cmptype="PopupItem" name="{self.name}" title="{self.placeholder}" rootitem="true" {split} caption="{self.caption}" id="d3ctrl{self.genName()}" {eventsStr} {atr}>53 <table style="width:100%" cmpparse="PopupItem" cont="item" onclick="{self.onclick};D3Api.PopupItemCtrl.clickItem(this);" onmouseover="{self.onmouseover};D3Api.PopupItemCtrl.hoverItem(this);">54 <tbody>55 <tr>56 <td class="itemCaption">57 <img src="{self.icon}" cont="itemIcon" class="itemIcon"><span cont="itemCaption">{self.caption}</span>58 </td>59 <td class="caret"></td>60 </tr>61 </tbody>62 </table>63 {subItems}64""")65 # ÐобавлÑеÑÑÑ Ð¿Ñи иниÑиализаÑии d3main.js d3theme.css66 # self.SetSysInfo.append("<scriptfile>Components/PopupMenu/js/PopupMenu.js</scriptfile>")...
__init__.py
Source:__init__.py
1#! /usr/bin/env python2# -*- coding: utf-8 -*-3# Copyright (C) 2011 ~ 2014 Deepin, Inc.4# 2011 ~ 2014 Hou ShaoHui5# 6# Author: Hou ShaoHui <houshao55@gmail.com>7# Maintainer: Hou ShaoHui <houshao55@gmail.com>8# 9# This program is free software: you can redistribute it and/or modify10# it under the terms of the GNU General Public License as published by11# the Free Software Foundation, either version 3 of the License, or12# any later version.13# 14# This program is distributed in the hope that it will be useful,15# but WITHOUT ANY WARRANTY; without even the implied warranty of16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17# GNU General Public License for more details.18# 19# You should have received a copy of the GNU General Public License20# along with this program. If not, see <http://www.gnu.org/licenses/>.21from PyQt5 import QtQml22from dtalk.gui.plugins.message import DMessage23from dtalk.gui.plugins.popup import PopupItem24QtQml.qmlRegisterType(DMessage, "DTalk", 1, 0, "DMessage")...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!