小编aft*_*pet的帖子

Tkinter - 无法绑定箭头键事件

我试图将左右箭头键绑定到Tkinter中的事件,但是当我运行程序时,它似乎没有触发事件.这是代码:

from Tkinter import *

main = Tk()

def leftKey(event):
    print "Left key pressed"

def rightKey(event):
    print "Right key pressed"

frame = Frame(main, width=100, height=100)
frame.bind('<Left>', leftKey)
frame.bind('<Right>', rightKey)
frame.pack()
frame.mainloop()
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

python tkinter

20
推荐指数
2
解决办法
4万
查看次数

WSL:无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器(2)

我正在尝试在适用于 Linux 的 Windows 子系统 (Ubuntu) 上使用全新安装的 MySQL,但似乎无法连接到它。我总是收到错误: WSL: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

我试过了:

  • 将配置切换为使用 localhost 而不是套接字(相反,我收到一条错误消息,提示我无法通过 localhost 连接)
  • --skip-grant-tables编辑/etc/mysql/mysql.conf.d/mysqld.cnf并重启即可使用

该文件/var/run/mysqld/mysqld.sock也从未显示出来,尽管我认为这是因为 WSL 一开始就没有完美的套接字支持,但它应该仍然可以工作。我怀疑问题可能是 WSL 特有的,也许我应该尝试更新到 WSL2?我不知道还有什么问题。

mysql windows-subsystem-for-linux

16
推荐指数
2
解决办法
4万
查看次数

Gradle同步中意外的块数据结束

我想在Android Studio v0.5.4中启动一个项目,但是我一直收到以下错误:

[ 130340]   WARN - nal.AbstractExternalSystemTask - Cause: unexpected end of block data 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cause: unexpected end of block data
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:206)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:116)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:64)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:467)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:546)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:464)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:373)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
Run Code Online (Sandbox Code Playgroud)

可能相关的是,当我尝试访问build.gradle时出现此错误:

InvalidVirtualFileAccessException: Accessing invalid virtual file: …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio

5
推荐指数
1
解决办法
6074
查看次数

从数据库项数组中获取属性数组

我的 Rails 应用程序中有一个模型类别,它有一个属性名称。添加另一个模型的项目时,我希望用户可以根据类变量@categories 从下拉列表中选择类别名称。

为此,我需要从 Category 类型的数组生成名称的字符串数组,但我不太确定如何在不将整个 Category 对象的字符串表示形式放入每个下拉项中的情况下执行此操作。

有谁知道如何做到这一点——从类对象数组中获取类属性数组?

ruby arrays ruby-on-rails

2
推荐指数
1
解决办法
2649
查看次数