working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,173 snippets matching: buttons

    public by PBMCube modified Jan 10, 2019  93  0  3  1

    Doors as Buttons

    Dungeon doorways should be both clickable and sense collisions.
    //Phaser III - clicking on a doorway  
    // ============
    // Example 4.6:  Doors as Buttons
    // ============
    // Creating door rectangles; review console in this experiment  
    //placed on a wall with 2px extended into the room
    doorN = this.add.rectangle(35,0,60,18,0x000000)  
            .setInteractive()  
            .setOrigin(0);  
    						

    public by lbottaro modified Oct 30, 2013  5971  44  7  0

    How to dynamically add a button to a GUI mask in python using PyQt4

    This code shows how to add some dynamic GUI controls (in this case QPushButton) to a GUI main window. In this example when user clicks on a button, the new buttons are created and put into the main window.
    #!/usr/bin/python
    import sys
    from PyQt4 import QtGui
    import os
    
    class Test(QtGui.QMainWindow):  
        def __init__(self):
            super(Test, self).__init__()
    
            self.initUI()
    
        def initUI(self):
            YDrive = QtGui.QAction("Y", self)
            YDrive.triggered.connect(self.setYDir)
    
            self.toolbar = self.addToolBar('Exit')
            self.toolbar.addAction(YDrive)
    
            self.setGeometry(300, 300, 250, 150)
            self.setWindowTitle('Message box')    
            self.show()
    
        def buttonClicked(self):
            print "clicked"
    
        def setYDir(self):
            myWorkDrive = "/tmp"
            shows = os.listdir(myWorkDrive)
            i = 0
            for elements in shows:
                btn1 = QtGui.QPushButton(elements, self)
                btn1.move(30, 50 + i)
                i += 30
                btn1.clicked.connect(self.buttonClicked)
                btn1.show()
            self.resize(self.width(), 50 + i)
    
    
    if __name__ == '__main__':
        app = QtGui.QApplication([])
        t = Test()
        t.show()
        app.exec_()

    public by dave83 modified Mar 10, 2014  5036  15  8  6

    Touch down event binding in Kivy framework

    This code shows how to handle a touch event in the python Kivy framework. This snippet will generate a simple GUI, with 2 standard buttons and a custom button, where to bind the press event. Any Kivy property has a default on_ event. This event is called when the value of the property is changed. In this case the on_touch_down(self, touch) meth
    from kivy.app import App
     from kivy.uix.widget import Widget
     from kivy.uix.button import Button
     from kivy.uix.boxlayout import BoxLayout
     from kivy.properties import ListProperty
    
     class RootWidget(BoxLayout):
    
         def __init__(self, **kwargs):
             super(RootWidget, self).__init__(**kwargs)
             self.add_widget(Button(text='btn 1'))
             cb = CustomBtn()
             cb.bind(pressed=self.btn_pressed)
             self.add_widget(cb)
             self.add_widget(Button(text='btn 2'))
    
         def btn_pressed(self, instance, pos):
             print ('pos: printed from root widget: {pos}'.format(pos=pos))
    
     class CustomBtn(Widget):
    
         pressed = ListProperty([0, 0])
    
         def on_touch_down(self, touch):
             if self.collide_point(*touch.pos):
                 self.pressed = touch.pos
                 # we consumed the touch. return False here to propagate
                 # the touch further to the children.
                 return True
             return super(CustomBtn, self).on_touch_down(touch)
    
         def on_pressed(self, instance, pos):
             print ('pressed at {pos}'.format(pos=pos))
    
     class TestApp(App):
    
         def build(self):
             return RootWidget()
    
    
     if __name__ == '__main__':
         TestApp().run()

    public by JKCPR modified May 27, 2016  3029  5  5  1

    SCSS button power @mixin

    one $color variable generates all buttons by @mixin and color @functions also leverages %placeholders and %placeholder-selectors
    //core values
    $font-size:16;
    $primary: #0085B7;
    $success: adjust_hue($primary, 260);
    $warning: saturate(adjust_hue($primary, 188), 43);
    $alert: lighten(saturate(adjust_hue($primary, 162), 12), 1);
    
    // function
    @function em($target, $context:$font-size){
      @return ($target/$context) * 1em;
    }
    
    //!default values
    $button-colour: $primary !default;
    $button-text-color: white !default;
    $button-line-height: 32 !default;
    $button-border-radius: 3 !default;
    $button-padding: 30 !default;
    $button-font-size: 24 !default;
    $button-weight: bold !default;
    
    //the btn mixin
    @mixin default-button($color: $button-text-color,
      $line-height: $button-line-height,
      $radius: $button-border-radius,
      $padding: $button-padding,
      $font-size: $button-font-size,
      $weight: $button-weight){
      
      color: $color;
      line-height: em($line-height);
      border-radius: em($radius);
      padding: 0 em($padding);
      font-size: em($font-size);
      font-weight: $weight;
    }
    
    @mixin flat-button($color: $button-color){
      $highlight-color: lighten($color, 50%);
      $shadow-color: grayscale(transparentize($color, 0.1));
    
      background-color: $color;
      border: 1px solid darken($color, 10%);
      text-shadow: 0px 1px 1px darken($color, 20%);
      box-shadow: 0 em(2) em(6) 0 $shadow-color;
      &:hover{
        background-color: darken($color, 5%);
        text-shadow: 1px 1px 1px darken($highlight-color, 5%);
      }
    }
    
    //placeholder selector
    %default-button{
      @include default-button;
    }
    .primary{
      @extend %default-button;
      @include flat-button($primary);  
    }
    .success{
      @extend %default-button;
      @include flat-button($success);
    }
    .warning{
      @extend %default-button;
      @include flat-button($warning);
    }
    .alert{
      @extend %default-button;
      @include flat-button($alert);
    }

    public by p.kontalis modified Mar 4, 2016  2883  0  4  0

    Batch Control Style

    Example regarding the control styling. This example applies a new color on all the buttons of your current form.
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      btn = Me.Controls.OfType(Of Button)().Where(Function(c) c.Name.Contains("")).ToArray()
    End Sub
    
    Private Sub Recolor()
      Dim i As Integer = 0
      While i < btn.Count
        btn(i).Enabled = True
        btn(i).BackColor = Color.Yellow
        i += 1
      End While
    End Sub
    
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Recolor()
    End Sub

    public by paulsimmons modified May 10, 2017  629  2  4  0

    Magento Facebook Login Extension by FMEAddons

    Magento Facebook login extension by FMEAddons allows the customers to connect on your website by using their Facebook profile. This addon enables 4 social login buttons on registration page which are Facebook, Twitter, Yahoo, and Gmail. Customers can select any of these social accounts to get the login to your website. Customers can now place the o
    // Enter here the actual content of the snippet.            

    public by simonwalker modified Jan 16, 2019  246  1  5  0

    Magento 2 Call For Price Extension By FME

    Magento 2 Call for price extension allows you to hide product prices from selected user groups or store views. You can replace the price option with ‘Get a quote’ popup, an image, or an alternative page. Subsequently, you can hide other Calls-to-action like ‘Add to Cart’, ‘Add to Wishlist’, and ‘Add to compare.’ Set conditions to restrict the price
    // code here 						

    public by msdn modified Jan 12, 2015  1269  0  5  0

    GetShowMessageBoxCancel: Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons

    Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.VisualStudio.Shell.Interop;
    using Microsoft.VsSDK.UnitTestLibrary;
    using Microsoft.VisualStudio;
    using Microsoft.Samples.VisualStudio.SourceControlIntegration.SccProvider;
    
    /// <summary>
            /// Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons
    		/// </summary>
    		/// <returns></returns>
            internal static BaseMock GetShowMessageBoxCancel()
    		{
    			BaseMock uiShell = GetUiShellInstance();
                string name = string.Format("{0}.{1}", typeof(IVsUIShell).FullName, "ShowMessageBox");
                uiShell.AddMethodCallback(name, new EventHandler<CallbackArgs>(ShowMessageBoxCancel));
    			return uiShell;
    		}

    public by msdn modified Jan 12, 2015  1224  0  5  0

    GetShowMessageBoxYes: Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons

    Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.VisualStudio.Shell.Interop;
    using Microsoft.VsSDK.UnitTestLibrary;
    using Microsoft.VisualStudio;
    using Microsoft.Samples.VisualStudio.SourceControlIntegration.SccProvider;
    
    /// <summary>
    /// Get an IVsUiShell that implement ShowMessageBox and returns Cancel from pressing the buttons
    /// </summary>
    /// <returns></returns>
    internal static BaseMock GetShowMessageBoxYes()
    {
        BaseMock uiShell = GetUiShellInstance();
        string name = string.Format("{0}.{1}", typeof(IVsUIShell).FullName, "ShowMessageBox");
        uiShell.AddMethodCallback(name, new EventHandler<CallbackArgs>(ShowMessageBoxYes));
        return uiShell;
    }

    public by msdn modified Jan 12, 2015  1053  0  7  0

    ShowOkCancelPopup: Shows a popup with OK/Cancel buttons and a message.

    Shows a popup with OK/Cancel buttons and a message. The message. True if the user selected ok, false if they selected cancel.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Citrix.XaAdminMobile.ViewModel;
    using Citrix.Cmp;
    
    /// <summary>
    /// Shows a popup with OK/Cancel buttons and a message.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <returns>True if the user selected ok, false if they selected cancel.</returns>
    public static bool ShowOkCancelPopup(string message)
    {
        PopupViewModel popupVm = new PopupViewModel();
        PopupWindow window = new PopupWindow();
        window.Title = Properties.Resources.PopupTitle;
    
        PopupButtonViewModel ok = new PopupButtonViewModel(window, PopupButtonType.OK);
        PopupButtonViewModel cancel = new PopupButtonViewModel(window, PopupButtonType.Cancel);
        PopupMessageViewModel messageVm = new PopupMessageViewModel(message);
    
        popupVm.AddMessage(messageVm);
        popupVm.AddButton(ok);
        popupVm.AddButton(cancel);
    
        window.DataContext = popupVm;
        ClientKeyboardController.HideKeyboard();
                
        App app = App.Current as App;
        if (null != app && null != app.MainWindow)
        {
            window.Owner = app.MainWindow;
        }
    
        return window.ShowDialog() ?? false;
    }
    • Public Snippets
    • Channels Snippets