好的,这种情况会影响我之前的问题:javascript custom alert box transparency issue
我试图获取它,以便有三个链接打开盒子而不是一个。我试图找出如何通过这些链接发送变量,然后运行switch语句来确定框中应显示的内容。
答案 0 :(得分:0)
简短回答(基于上一个问题中的标记):只需将参数传递给您正在执行时调用的函数:
from Tkinter import *
ICON = """
R0lGODlhMgAyAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBV
ZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDV
mQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMr
zDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq
/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2Yr
AGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaq
M2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kA
ZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlVM5lVZplVmZlVzJlV/5mAAJmAM5mAZpmA
mZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/
zJn//8wAAMwAM8wAZswAmcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV
/8yAAMyAM8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV/8z/
AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8rAP8rM/8rZv8rmf8rzP8r//9VAP9V
M/9VZv9Vmf9VzP9V//+AAP+AM/+AZv+Amf+AzP+A//+qAP+qM/+qZv+qmf+qzP+q///VAP/VM//V
Zv/Vmf/VzP/V////AP//M///Zv//mf//zP///wAAAAAAAAAAAAAAACH5BAEAAPwALAAAAAAyADIA
AAj/APcJHEiwoMGDCBMqXCjQnsOHECEynIgQIjx7FzNi3HjRIcWPHC0+7LixpL2PCk2GXNmx5UaU
BkW6NDlzpkeY+xxq1MmTZU+XF2GWrNnz50ijJykO5Um0KdKgDI+qJEm1KM2fC3cCZYrU59KbFb1O
NVr1a8aEY30SlWqTZNKYK6+a5eqU48GiO0sC2Mu3I9++XUkWXFq15d+9Og8DeMqVoE28DhX7PdzW
KkGyXDEqTnyYcciBmOVKjkyZLeSGleVGtHp0reB9qZ1qLJyWaMO5X+Xm3ToXHmrPdWkHLnob91rC
rYFjFKhVeVfIuV+b3shXeXN71Zv+zv3X9fS/05MyoIbX2fvQ8mSZQyedXTn63LedbjaOvTPj7Y/r
g8e9+XrH+JhdNN9XA96nXnQP9dfTfP6BlRN9Ag6o2GLIDXWZeQlOOOFwPA0GIXsaIvahQebNFOJ0
j91VImsyKYdWWcfNpptpKXmFYWxSZYXijhXWNNGM9NXWoVJBxjgXTCsWOSSS0CXpEk6X2eicb1DC
hduVVSIEY5MOZhnWli95KaaXAQEAOw==
"""
class ChildWindow(Toplevel):
def __init__(self, callingFrame):
self.parent = callingFrame
Toplevel.__init__(self)
self.title("Child")
self.initUI()
def initUI(self):
#this doesn't work in this class, unlike the first class where it does work.
global ICON
self.icon = PhotoImage(data=ICON)
self.call('wm', 'iconphoto', self.parent._w, self.icon)
btn = Button(self, text="Close", command=self.destroy)
btn.pack()
class ParentWindow(object):
def __init__(self, parent):
self.parent = parent
self.parent.title("Parent")
self.frame = Frame(parent)
self.initUI()
def initUI(self):
global ICON
self.icon = PhotoImage(data=ICON)
self.parent.call('wm', 'iconphoto', self.parent._w, self.icon)
btn = Button(self.parent, text="Child", command=self.opennew)
btn.pack()
def opennew(self):
newwin = ChildWindow(self)
def main():
root = Tk()
win = ParentWindow(root)
root.geometry()
root.mainloop()
if __name__ == '__main__':
main()
答案越长,您应该将其移出<a href="javascript:DlgShow('someParameter');">Open</a>
属性,甚至可以将其移出锚标记并进入按钮。然后,添加一个事件监听器,而不是内联javascript。对于您的示例,三个按钮基于开关案例在href
中显示某些内容:
alert
然后你的javascript:
<button id="one">One</button>
<button id="two">Two</button>
<button id="three">Three</button>