我已经为Surface pro 4开发了一个WinJs应用程序。该应用程序以全屏模式运行,并且屏幕分辨率为2736x1824(表面分辨率)。
现在,当我在表面上启动应用程序时,DPI缩放开始起作用并且弄乱了我的布局。
有没有办法禁用该应用的缩放?
我试过了:
from Tkinter import *
import RPi.GPIO as GPIO
root = Tk()
root.geometry("320x480")
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN,pull_up_down=GPIO.PUD_UP)
shootdelay = 12 #12
shootinterval = 7#7
shootnumber = 5#12
videodelay = 3
selft = 5
newset = 0
endvideo = 5
intertext = "(D:" + str(shootdelay) + ")(I:" + str(shootinterval) + ")(T:" + str(shootnumber) + ")"
flagselftim = 0
flagvideo = 0
videosetmode = 0
flagsetings = 0
flagcancel = 0
flagnewset = 0
secDelay = shootdelay
secInterv = shootinterval
secSelftim = selft
secvideo = videodelay
remainshots = shootnumber
secshoots = shootnumber - 1
seccompte = 0
readyshoots =
class intervalometer:
def __init__(self, master):
self.textBox = Text(root, height=1, width=1, relief=SUNKEN, font=('arial narrow', 17, 'normal'), bg="green",
fg="white")
self.textBox.grid(row=1, column=1, padx=3, pady=2, sticky=NSEW)
self.textBox.insert(END, "READY")
self.botshoot = Button(root, width=18, font=('arial narrow', 19, 'normal'), text="START",
activebackground="#00dfdf")
self.botshoot.grid(row=4, rowspan=2, column=0, columnspan=2, ipady=15, pady=2, sticky=NSEW)
self.botshoot.configure(command=self.start)
self.botStop = Button(root, heigh=2, font=('arial', 18, 'normal'), text="STOP/RESET", activebackground="red")
self.botStop.grid(row=13, rowspan=3, column=0, pady=1, sticky=NSEW)
self.botStop.configure(state=DISABLED, command=self.stop)
self.botQuit = Button(root, width=3, font=('arial', 18, 'normal'), text="QUIT", activebackground="red",
state=NORMAL)
self.botQuit.grid(row=13, rowspan=3, column=1, pady=1, sticky=NSEW)
self.botQuit.configure(command=self.closewindow)
GPIO.add_event_detect(18, GPIO.RISING, callback=self.start, bouncetime=200)
def start(self, *args, **kwargs):
global flagselftim
self.count = 0
self.cancel_id = None
self.botshoot.configure(state=DISABLED)
self.botStop.configure(state=NORMAL)
self.botQuit.configure(state=DISABLED)
self.start_shoot_delay()
def stop(self):
global secDelay
global secSelftim
global selft
global flagvideo
global videosetmode
global secvideo
global remainshots
global secInterv
global readyshoots
flagvideo = 0
videosetmode = 0
secDelay = shootdelay
secInterv = shootinterval
secvideo = videodelay
selft = 5
secSelftim = selft
remainshots = shootnumber
readyshoots = 1
if self.cancel_id is not None:
self.textBox.after_cancel(self.cancel_id)
self.cancel_id = None
self.textBox.insert(END, 0)
self.textBox.delete("1.0", END)
self.botshoot.configure(text="START")
self.botshoot.configure(state=NORMAL)
self.botStop.configure(state=DISABLED)
self.botQuit.configure(state=NORMAL)
self.textBox.insert(END, "READY")
self.textBox.configure(font=('arial narrow', 17, 'normal'), bg="green", fg="white")
def closewindow(self):
root.destroy()
def start_shoot_delay(self):
global secDelay
if secDelay > 9:
contador = " " + str(secDelay)
else:
contador = " " + str(secDelay)
self.textBox.delete("1.0", END)
self.textBox.configure(font=('arial narrow', 17, 'normal'), bg="red", fg="white")
self.botshoot.configure(state=DISABLED)
if self.count < shootdelay:
self.count += 1
self.textBox.insert(END, contador)
self.cancel_id = self.textBox.after(1000, self.start_shoot_delay)
secDelay -= 1
else:
self.count = 0
secDelay = shootdelay
self.start_shoot_interval()
def start_shoot_interval(self):
global secInterv
if remainshots == shootnumber:
self.start_shootings()
else:
if secInterv > 9:
contador = " " + str(secInterv)
else:
contador = " " + str(secInterv)
self.textBox.delete("1.0", END)
self.textBox.configure(font=('arial narrow', 17, 'normal'), bg="red", fg="white")
if self.count < shootinterval:
self.count += 1
self.textBox.insert(END, contador)
self.cancel_id = self.textBox.after(1000, self.start_shoot_interval)
secInterv -= 1
else:
self.count = 0
secInterv = shootinterval
self.start_shootings()
def start_shootings(self):
global remainshots
global videosetmode
global readyshoots
global secSelftim
global selft
remainshots -=1
if secSelftim <5:
txtremain = "SHOOTING = " + str(1) + "/" + str(1)
else:
txtremain = "REMAINING = " + str(remainshots) + "/" + str(shootnumber)
print "BEEP shoot nr",readyshoots, "av", shootnumber
readyshoots +=1
if remainshots >0:
self.start_shoot_interval()
else:
print "BEEP-BEEP-BEEP : end of roll"
self.etstatus.configure(text="END OF ROLL")
root.update_idletasks()
root.after(500)
readyshoots = 1
selft = 5
self.textBox.insert(END, "READY")
self.textBox.configure(font=('arial narrow', 17, 'normal'), bg="green", fg="white")
self.botshoot.configure(state=NORMAL)
self.botStop.configure(state=DISABLED)
self.botQuit.configure(state=NORMAL)
remainshots = shootnumber
intervalometer(root)
root.mainloop()
但这似乎不起作用。
答案 0 :(得分:0)
实际上,只为一个分辨率制作你的应用布局,特别是对于如此大的分辨率并不是一个好主意,因为该应用可以在设备上运行,例如1920x1080分辨率,即使禁用DPI缩放,你的布局也会搞砸
所以我建议让应用布局做出响应,这样每个分辨率都会正确。
答案 1 :(得分:0)
不确定您是否仍在查看此问题,但我发现您在整个地方看到的代码实际上只是XBox(Link To Docs)
微软开发人员已经说了一段时间,这是一个基于用户的设置,他们不打算允许你使用ds(Forum Link)
您可以使用ResolutionScale
(docsLink)
Windows.Graphics.Display.DisplayInformation.getForCurrentView().resolutionScale
Here's a link到检测到并调整的样本。
所以你可以做什么(以及我做了什么)在需要的地方我使用css scale来调整系统以适应。我的大多数应用程序都是响应式的,所以它并不重要,但如果你使用iFrame并将其设置为1000px宽,这个比例因子实际上是1400px甚至1800px宽并完全切断..
我有调整大小事件的侦听器设置,只需根据需要进行调整。
希望有所帮助!
丹尼斯