标签: button

更改默认按钮高亮 WPF

我试图删除 a 上的默认背景Button,但是Button当用户用鼠标悬停在按钮上时,将其突出显示为橙色。到目前为止,这是我想出的;

<Window.Resources>
    <Style TargetType="{x:Type Button}">
        <Setter Property="FontSize" Value="20" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="MaxHeight" Value="30" />
        <Setter Property="Width" Value="150" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Cursor" Value="Hand" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Orange"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

但是,当用户将鼠标悬停在按钮上时,它仍然以默认的蓝色突出显示,而不是我想要的橙色。如何修改它,以便按钮的文本逐渐以橙色突出显示?

c# wpf xaml button

4
推荐指数
1
解决办法
4470
查看次数

kivy python 通过单击按钮将参数传递给函数

按下按钮调用函数时,我无法将参数传递给函数。可以用 kivy 语言这样做:

Button: 
   on_press: root.my_function('btn1')
Run Code Online (Sandbox Code Playgroud)

但我想用 python 来做,因为我想用循环创建更多数量的按钮。目前我在 python 中调用我的函数是这样的:

Button(on_press=self.my_function)
Run Code Online (Sandbox Code Playgroud)

但正如我所说,如果我尝试将参数传递给这样的函数,我会收到“AssertionError: None is not callable”,如下所示:

Button(on_press=self.my_function('btn1'))
Run Code Online (Sandbox Code Playgroud)

python function button kivy

4
推荐指数
1
解决办法
4203
查看次数

如何在 Tkinter 中定位按钮?

我这里有一个程序,里面有两个按钮。我正在尝试将它们的位置更改为它们之间的空间,因为目前它们直接位于彼此下方。我应该怎么做才能改变按钮的位置?

def menu():
    import tkinter
    window=tkinter.Tk()
    window.title('Lightning Parties')
    window.configure(background='turquoise')
    lbl=tkinter.Label(window, text='Welcome to Lightning Parties!', fg='purple', bg='turquoise', font=('comicsans', 14))
    lbl.pack()

    #here are the buttons
    lbl=tkinter.Button(window, text='Returning customer options', fg='white',   bg='purple', font=('comicsans', 12),command=combine_funcs(window.destroy, customer_login))
    lbl.pack()

    lbl=tkinter.Button(window, text='Register as a customer', fg='white', bg='purple', font=('comicsans', 12),command=combine_funcs(window.destroy, customer_details))
    lbl.pack()
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!

python position tkinter button

4
推荐指数
1
解决办法
6万
查看次数

仅用于角落边框的 CSS

我需要关于如何使按钮看起来像这样的想法:

在此处输入图片说明

我不知道如何制作这样的方角,我在网上找不到任何解决方案。此外,在悬停时,边框应该围绕按钮(只是一个普通的 2px 边框。)

css button

4
推荐指数
1
解决办法
6267
查看次数

任何视图的 R.id(最小和最大整数值)的范围是多少

我正在创建一个 android 应用程序,我想在其中创建 ID 最大值大小的布尔数组,以便我可以唯一地存储按钮上的更改。

假设我的按钮 id 是 102931,当用户单击按钮时,我将更改布尔数组的第 102931 个元素,以便稍后我可以检查其中更改的值。

现在我的问题是

任何视图的 ID(最小-最大)范围是多少?

android boolean view button android-resources

4
推荐指数
1
解决办法
993
查看次数

Python Tkinter:在框架中放置按钮

我正在尝试创建不同的框架并切换/销毁它们,以便您可以像在普通 iOS 应用程序中一样在窗口之间移动。

为此,我需要将小部件(组件)放置在框架(容器)中。

但是,当我尝试向框架添加按钮时,它不会将其打包到右侧。

这是我的代码: from tkinter import *

root=Tk()
root.geometry('500x500')
root.title('Good morning :)')

frame1=Frame(root,width=500,height=500,bg='green')
frame1.pack()

button1=Button(frame1,text='Hello')
button1.pack(side='bottom')
Run Code Online (Sandbox Code Playgroud)

tkinter button

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

绑定到 DataTemplate 内按钮的命令不起作用

例子:

<ListBox Name="List" 
             ItemsSource="{Binding Items}" 
             SelectedIndex="{Binding SelectedIndex}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <DockPanel >
                    <Button DockPanel.Dock="Left" Content="Show" Command="{Binding ShowCommand}" CommandParameter="{Binding}"/>
                    <TextBlock Text="{Binding }"/>
                </DockPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
Run Code Online (Sandbox Code Playgroud)

单击按钮什么也不做。我试图将命令绑定到 外面的按钮DataTemplate并且它起作用了。我还尝试将按钮注册DataTemplate到 a 中Click_event,这确实有效。

为什么该命令在 DataTemplate 中不起作用?

wpf command button datatemplate

4
推荐指数
1
解决办法
1676
查看次数

将 Woocommerce 单个产品页面上的添加到购物车按钮替换为产品类别

我正在尝试添加一个指向联系页面的自定义链接按钮 - 首先,如果条件显示“联系我们”文本和按钮上的自定义 URL,而不是“添加到购物篮”按钮。

怎么做?到目前为止,这是我的代码。它显示属于“64”类别的每个产品的自定义按钮文本。这正是我想要的。但是如何添加该按钮将功能从购物车按钮更改为自定义链接按钮?我想如果必须更改此购物车按钮功能。如何?

add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );

function woo_custom_cart_button_text() {
    global $product;
    $cat_id = 64;

    $product->get_category_ids();
    if ( in_array( $cat_id, $product->get_category_ids() ) ) {
        return __( 'Contact us', 'woocommerce' );
    }
    else {
        return __( 'Add to Basket', 'woocommerce' );
    }
}
Run Code Online (Sandbox Code Playgroud)

php wordpress product button woocommerce

4
推荐指数
1
解决办法
7732
查看次数

如何在 Android 中以编程方式更改按钮大小?

我正在创建按钮并以编程方式将它们添加到 LinearLayout。但是,我正在努力更改按钮大小。在下面的代码中,无论我在 deleteBtn.setWidth(num) 和 deleteBtn.setHeight(num) 中输入什么数字,都没有任何变化。

private void populateHorizontalLayouts(CustomMessageEvent event) {
    // Need to remove all views each time an user adds a number
    // so that the same number is not rendered multiple times.

    nameAndNumbersLayout.removeAllViews();

    //displayedNamesAndNumbers.add(event.getCustomMessage());
    for(int i =0; i < displayedNamesAndNumbers.size(); i++){
        String displayedNumberAndName = displayedNamesAndNumbers.get(i);

        LinearLayout horizontalLayout = new LinearLayout(view.getContext());
        horizontalLayout.setOrientation(LinearLayout.HORIZONTAL);
        horizontalLayout.setId(i);

        Button deleteBtn = new Button(view.getContext());
        deleteBtn.setId(i);
        deleteBtn.setText("Delete");
        deleteBtn.setWidth(5);
        deleteBtn.setHeight(5);

        TextView nameAndNumView = new TextView(view.getContext());
        nameAndNumView.setId(i);
        nameAndNumView.setText(displayedNumberAndName);

        horizontalLayout.addView(deleteBtn);
        horizontalLayout.addView(nameAndNumView);

        nameAndNumbersLayout.addView(horizontalLayout);
    }
}
Run Code Online (Sandbox Code Playgroud)

我应该写什么才能改变按钮大小?

android button

4
推荐指数
1
解决办法
7215
查看次数

在新标签页中打开链接的按钮

我正在制作一个网站,当我单击一个按钮时,我希望在特定地址打开一个新选项卡。

这是我的按钮的 html:

<button id="AsDownload" onclick="AsDownload();">Download</button>
Run Code Online (Sandbox Code Playgroud)

这是我的javascript:

function AsDownload(){
    chrome.tabs.create({url:"https://alexanderhawking.itch.io/asteroid-racer"});
};
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我不知道为什么,有人可以帮助我吗?

html javascript button web

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