我正在使用 Tkinter 制作 GUI 并驱动机器人。
我有4个按钮:FORWARD,RIGHT,BACKWARD和LEFT。我想让机器人在按下 Button 时移动,并在松开 Button 时停止。
如何识别 Button 在 Tkinter 中何时被释放?
我想在用户按住 Button 时打开上下文菜单(为了方便起见,我使用 Button)。如果我做
Button
{
text: model.ualabel
MouseArea
{
preventStealing: true
anchors.fill: parent
onPressAndHold: uaContextMenu.open()
}
ContextMenu
{
id: uaContextMenu
MenuLayout
{
MenuItem { /**/ }
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后负责 pressAndHold 的 MouseArea 会窃取所有手势,即使无法单击 Button。我究竟做错了什么?我正在使用 Qt 4.7 并导入QtQuick 1.1和com.nokia.meego 1.0
谢谢
我正在使用 VB.NET,我有:
Start按钮Stop按钮While循环当Start按下按钮时,While循环开始。我想在Stop按下按钮时停止循环。
我曾尝试使用Applications.DoEvents,但当Stop按下按钮两次时循环停止。
下面是我的代码使用 Applications.DoEvents
Dim stopclick As Boolean = False
Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.Click
btnForward.Enabled = False
btnStop.Enabled = True
While
' Perform the while statements
If stopclick = True Then
stopclick = False
Application.DoEvents()
Exit While
End If
End While
End Sub
Private Sub btnStop_Click(ByVal sender As Object, …Run Code Online (Sandbox Code Playgroud) 我是 Python 新手,我正在尝试使用 Tkinter 制作一个简单的应用程序。
def appear(x):
return lambda: results.insert(END, x)
letters=["A", "T", "D", "M", "E", "A", "S", "R", "M"]
for index in range(9):
n=letters[index]
nButton = Button(buttons, bg="White", text=n, width=5, height=1,
command =appear(n), relief=GROOVE).grid(padx=2, pady=2, row=index%3,
column=index/3)
Run Code Online (Sandbox Code Playgroud)
我想要做的是一旦我点击它们就禁用它们。我试过
def appear(x):
nButton.config(state="disabled")
return lambda: results.insert(END, x)
Run Code Online (Sandbox Code Playgroud)
但它给了我以下错误:
NameError:未定义全局名称“nButton”
我有 a<div>和 a <button>,但由于某种原因,按钮不会留在 div 中。
我试图清除 div,float: left但它没有帮助。
我也添加padding到 div 的底部,但我认为这不是解决方案。
我的代码:
<div class="service-text text2">
<p>
this is some text
</p>
<a href="" class="button-learn centered"><i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试设置一个列表框,用户可以通过单击他们想要删除的每个值来删除项目。我为我的列表框设置了样式(DisplayName 是项目类的成员),以便为每个项目包含一个按钮:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DisplayName}" />
<Button Content="[x]" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
现在我在尝试设置按钮以删除相关条目时遇到问题。有人可以指点一下吗?先感谢您。
我正在寻找一种简单的方法,使用单个标签(仅<a>)在边框上创建倾斜效果,但保持文本的原样。
我会知道如何处理内部或外部的跨度,但我不想在页面上有额外的、几乎为零的 HTML。
下面举例。

如何在下图中放置drawableLeft和按钮AppCompatButton类似的文本?
我试图申请paddingLeft,但文本正在远离可绘制的右侧。
<android.support.v7.widget.AppCompatButton
android:id="@+id/filterBy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_filter"
android:paddingLeft="20dp"
android:text="@string/filter_by"
android:textAllCaps="false" />
Run Code Online (Sandbox Code Playgroud)
到目前为止,结果看起来像
布局
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profileHeader"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp">
<android.support.v7.widget.AppCompatButton
android:id="@+id/findFriends"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_search"
android:text="@string/find_friends"
android:textAllCaps="false" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/filterBy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_filter"
android:text="@string/filter_by"
android:textAllCaps="false" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
以及使事情变得清晰的解释性要求。
使用
layout_weight属性 am 调整两个按钮的宽度,我必须做的是,文本应该在按钮的中心,drawable 应该在文本的左侧附近对齐。
请问有什么建议吗?
我创建了一个按钮,我希望在单击时调用一个函数,然后在释放时再次调用该函数。普通的 TouchableOpacity 或其他只会在释放点击时触发一个功能,我需要点击和释放的功能。
<View
style={styles.touchbutton}
onStartShouldSetResponder={() => this.clickOn()}
onResponderRelease={() => this.clickRelease()}>
<Text style={styles.dark}>Button</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
上面的代码在点击时有效,但在发布时无效。我也试过 onResponderReject 但这也不起作用。很难找到命令应该是什么。
我正在尝试将水平线性布局内的按钮与我的 Android 应用程序中的屏幕右侧对齐。
我怎样才能做到这一点?我在属性窗格中找不到对齐选项。 我尝试了一些谷歌搜索,但我找不到太多东西,因为我不知道要搜索的正确术语。
这是一个渲染,所以你可以得到一个想法:
这是我的当前 activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_gravity="center_vertical" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button3" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间!