精华内容
下载资源
问答
  • 在刚开始接触Orchard CMS,对于个性化的网页布局不知道怎么定义,通过google的帮助终于找到比较符合Orchard的二次开发方法的解决方案,就是在Theme定义布局Widgets Layout。需要注意的是,因为要在Theme写C#代码,...

        因为公司业务需要,经过本人几个月尝试,使用Orchard CMS 开发一个简单的企业门户(地址是http://www.ubof.cn)。在刚开始接触Orchard CMS,对于个性化的网页布局不知道怎么定义,通过google的帮助终于找到比较符合Orchard的二次开发方法的解决方案,就是在Theme定义布局Widgets Layout。需要注意的是,因为要在Theme写C#代码,所以要用Orchard 命令提示创建Theme的解决方案(命令:codegen theme <theme-name> /CreateProject:true)。

         当Theme的解决方案方案建立好后我们就可以开始定义自己的Widgets Layout,在这里我以自己网站上首页的一个产品展示Widgets为例子说明(此为新开发没有同步到发布站点),最后实现好的效果如下:

           

        下面开始介绍代码的编写,第一步需要在刚建好的Theme的解决方案里,新建名称为Providers的文件夹,第二步在建好Providers文件里新建ProductsListLayoutForms的类,它必须实现Orchard里的 IFormProvider 接口,这个类主要作用是为Widgets 中HTML DOM的Id,class 提供配置表单,为以后修改class和id提供方便,具体代码如下:

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Orchard.DisplayManagement;
    using Orchard.Forms.Services;
    using Orchard.Localization;
    
    namespace UBOfficeTheme.Providers.Layouts
    {
        public class ProductsListLayoutForms : IFormProvider
        {
            protected dynamic Shape { get; set; }
            public Localizer T { get; set; }
    
            public ProductsListLayoutForms(IShapeFactory shapeFactory)
            {
                Shape = shapeFactory;
                T = NullLocalizer.Instance;
            }
    
            public void Describe(DescribeContext context)
            {
                Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = Shape.Form(
                            Id: "ProductsListLayout",
                             _HtmlProperties: Shape.Fieldset(
                               Title: T("Html properties"),
                                  _ListId: Shape.TextBox(
                                        Id: "culture-id",
                                        Name: "CultureId",
                                        Title: T("culture id"),
                                        Description: T("The id to provide on the culture div element."),
                                        Classes: new[] { "textMedium", "tokenized" }
                                   ),
                                   _ListClass: Shape.TextBox(
                                        Id: "culture-classes",
                                        Name: "CultureClasses",
                                        Title: T("culture classes"),
                                        Description: T("The class to provide on the culture div element."),
                                        Classes: new[] { "textMedium", "tokenized" }
                                   ),
                                   _CultureTitle: Shape.TextBox(
                                        Id: "culturetitle-classes",
                                        Name: "CultureTitleClasses",
                                        Title: T("culture title classes"),
                                        Description: T("The class to provide on the culturetitle div element."),
                                        Classes: new[] { "textMedium", "tokenized" }
                                   ),
                                   _ProductsId:Shape.TextBox(
                                        Id: "products-id",
                                        Name: "ProductsId",
                                        Title: T("products id"),
                                        Description: T("The id to provide on the products div element."),
                                        Classes: new[] { "textMedium", "tokenized" }
                                   ),
                                   _ProductsClass:Shape.TextBox(
                                        Id: "products-classes",
                                        Name: "ProductsClasses",
                                        Title: T("products classes"),
                                        Description: T("The class to provide on the products div element."),
                                        Classes: new[] { "textMedium", "tokenized" }
                                   )
                             )
                        );
    
                    return f;
                };
                context.Form("ProductsListLayout", form);
            }
        }
    }
    

     第三步需要新建一个ProductsListLayout的类,此类必须实现Orchard里ILayoutProvider接口,此类的作用有两点,第一:为Projections(后面章节有说明)选择布局供时提供布名称和说明,第二:调用构造具体布局的实现,并提供class 和 id传参,具体代码如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Orchard.ContentManagement;
    using Orchard.DisplayManagement;
    using Orchard.Localization;
    using Orchard.Projections.Descriptors.Layout;
    using Orchard.Projections.Models;
    using Orchard.Projections.Services;
    
    namespace UBOfficeTheme.Providers.Layouts
    {
        public class ProductsListLayout : ILayoutProvider
        {
            private readonly IContentManager _contentManager;
            protected dynamic Shape { get; set; }
            public Localizer T { get; set; }
    
            public ProductsListLayout(IShapeFactory shapeFactory, IContentManager contentManager)
            {
                _contentManager = contentManager;
                Shape = shapeFactory;
                T = NullLocalizer.Instance;
            }
    
            public void Describe(DescribeLayoutContext describe)
            {
                describe.For("Html", T("Html"), T("Html Layouts"))
                 .Element("ProductsList", T("ProductsList"), T("Organizes content items in a ProductsList."),
                         DisplayLayout,
                         RenderLayout,
                         "ProductsListLayout"
                        );
            }
    
            public dynamic RenderLayout(LayoutContext context, IEnumerable<LayoutComponentResult> layoutComponentResults)
            {
                string cultureId = context.State.CultureId;
                string cultureClasses = context.State.CultureClasses;
                string culturetitleClasses = context.State.CultureTitleClasses;
                string productsId = context.State.ProductsId;
                string productsClasses = context.State.ProductsClasses;
    
                IEnumerable<dynamic> shapes =
                                   context.LayoutRecord.Display == (int)LayoutRecord.Displays.Content
                                   ? layoutComponentResults.Select(x => _contentManager.BuildDisplay(x.ContentItem, context.LayoutRecord.DisplayType))
                                   : layoutComponentResults.Select(x => x.Properties);
    
                return Shape.ProductsList(
                         Id: cultureId,
                         Items: shapes,
                         pcultureClasses: new[] { cultureClasses },
                         pculturetitleClasses: new[] { culturetitleClasses },
                         productsClasses: new[] { productsClasses },
                         productsId : productsId
                    );
            }
    
            public Func<LayoutContext, LocalizedString> DisplayLayout { get; set; }
        }
    }
    

     第四步新建一个LayoutShapes 此类必须实现Orchard里IDependency接口,此类的作用为本Theme解决方案里的所有自定义布局提供具体实现,定义布局方法是有三点需要注意,第一:在方法前必须要加上 [Shape]的属性,第二点:方法名称必须和ProductsListLayout类中的RenderLayout方法返回语句中Shape调用名称相同。第三点:定义的方法参数除去dynamic Display, TextWriter Output, HtmlHelper Html由Orchard本身框架提供,其余一部由ProductsListLayout类中的RenderLayout方法返回语句中的Shape调用方法传递,一部是自己定义给class使用的字典集合。具体代码如下:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.Mvc;
    using Orchard;
    using Orchard.Autoroute.Models;
    using Orchard.ContentManagement;
    using Orchard.DisplayManagement;
    using Orchard.Localization;
    using Orchard.UB.Portal.Models;
    using Orchard.UI.Resources;
    
    namespace UBOfficeTheme.Providers.Layouts
    {
        public class LayoutShapes : IDependency
        {
            private readonly IWorkContextAccessor _workContextAccessor;
            private readonly IContentManager _contentManager;
            private readonly IOrchardServices _orchardServices;
    
            public Localizer T { get; set; }
    
            public LayoutShapes(IOrchardServices orchardServices,
                IWorkContextAccessor workContextAccessor, IContentManager contentManager)
            {
                _workContextAccessor = workContextAccessor;
                T = NullLocalizer.Instance;
                _contentManager = contentManager;
                _orchardServices = orchardServices;
            }
    
    
            [Shape]
            public void ProductsList(dynamic Display, TextWriter Output, HtmlHelper Html, string Id,
                IEnumerable<dynamic> Items, 
                IEnumerable<string> pcultureClasses,
                IDictionary<string, string> pcultureAttr,
                IEnumerable<string> pculturetitleClasses,
                IDictionary<string, string> pculturetitleAttr,
                IEnumerable<string> productsClasses,
                IDictionary<string, string> productsAttr,
                string productsId)
            {
                if (Items == null) return;
    
                var items = Items.ToList();
                var itemsCount = items.Count;
                if (itemsCount < 1) return;
    
                string baseUrl = _workContextAccessor.GetContext().CurrentSite.BaseUrl;
                var cultureDivTag = GetTagBuilder("div", Id, pcultureClasses, pcultureAttr);
                var cultureDivTitleTag = GetTagBuilder("div", string.Empty, pculturetitleClasses, pculturetitleAttr);
    
                var proddetailDivTag = GetTagBuilder("div", productsId, productsClasses, productsAttr);
                var proddetailUlTag = GetTagBuilder("ul", productsId, productsClasses, productsAttr);
    
                Output.Write(cultureDivTag.ToString(TagRenderMode.StartTag));
                Output.Write(cultureDivTitleTag.ToString(TagRenderMode.StartTag));
                Output.Write("<h6 class='fl'><strong></strong>新品推荐<span>NEW PRODUCTS</span></h6>");
                Output.Write(string.Format("<a href='{0}/{1}' class='fr'></a>", baseUrl, "executivedesk"));
                Output.Write(cultureDivTitleTag.ToString(TagRenderMode.EndTag));
                Output.Write("<div>");
                Output.Write(proddetailDivTag.ToString(TagRenderMode.StartTag));
                Output.Write("<a href=\"javascript:void(0)\" id=\"prev\" ></a>");
                Output.Write("<div>");
                   Output.Write(proddetailUlTag.ToString(TagRenderMode.StartTag));
                   for (int i = 0; i < items.Count; i++)
                   {
                       var pictureField = ((Orchard.ContentManagement.ContentItem)items[i].ContentItem).Parts.SelectMany(p => p.Fields).Where(f => f.Name.Contains("picture")).SingleOrDefault();
                       var imglist = ((Orchard.MediaLibrary.Fields.MediaLibraryPickerField)pictureField).MediaParts.OrderBy(c => c.AlternateText).ToList();
                       foreach (var item in imglist)
                       {
                           Output.Write("<li><a href='{2}/{3}'><img src='{0}' alt='优比家具-{1}'/></a></li>", item.MediaUrl, item.Title, baseUrl,item.Caption);
                       }
                   }
                   Output.Write(proddetailUlTag.ToString(TagRenderMode.EndTag));
                Output.Write("</div>");
                Output.Write("<a href=\"javascript:void(0)\" id=\"next\" ></a>");
    
                Output.Write(proddetailDivTag.ToString(TagRenderMode.EndTag));
                Output.Write(cultureDivTag.ToString(TagRenderMode.EndTag));
    
            }
    
            static TagBuilder GetTagBuilder(string tagName, string id, IEnumerable<string> classes, IDictionary<string, string> attributes)
            {
                var tagBuilder = new TagBuilder(tagName);
                tagBuilder.MergeAttributes(attributes, false);
                foreach (var cssClass in classes ?? Enumerable.Empty<string>())
                    tagBuilder.AddCssClass(cssClass);
                if (!string.IsNullOrWhiteSpace(id))
                    tagBuilder.GenerateId(id);
                return tagBuilder;
            }
        }
    }
    

     到这里代码编写全部完成。下一篇介绍配置。

        

    转载于:https://www.cnblogs.com/ww5552031/p/3470835.html

    展开全文
  • 本文整理汇总了Python中PySide2.QtWidgets.QPushButton方法的...Python QtWidgets.QPushButton怎么用?Python QtWidgets.QPushButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可...

    本文整理汇总了Python中PySide2.QtWidgets.QPushButton方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QPushButton方法的具体用法?Python QtWidgets.QPushButton怎么用?Python QtWidgets.QPushButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块PySide2.QtWidgets的用法示例。

    在下文中一共展示了QtWidgets.QPushButton方法的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

    示例1: __init__

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, parent=None):

    super(BrowseEdit, self).__init__(parent)

    self.text = QtWidgets.QLineEdit()

    self.text.returnPressed.connect(self.apply)

    self.button = QtWidgets.QPushButton('B')

    self.button.setFixedSize(21, 21)

    self.button.released.connect(self.browse)

    self.layout = QtWidgets.QHBoxLayout(self)

    self.layout.setContentsMargins(0, 0, 0, 0)

    self.layout.setSpacing(0)

    self.layout.addWidget(self.text)

    self.layout.addWidget(self.button)

    self._value = self.value()

    开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:18,

    示例2: __init__

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, command, parent=None):

    super(CommandDisplayDialog, self).__init__(parent)

    self.setWindowTitle("Command")

    self.text = QtWidgets.QTextEdit()

    self.text.setReadOnly(True)

    self.text.setPlainText(command)

    self.ok = QtWidgets.QPushButton('ok')

    self.ok.released.connect(self.accept)

    self.button_layout = QtWidgets.QHBoxLayout()

    self.button_layout.setContentsMargins(0, 0, 0, 0)

    self.button_layout.addStretch(1)

    self.button_layout.addWidget(self.ok)

    self.layout = QtWidgets.QVBoxLayout(self)

    self.layout.addWidget(self.text)

    self.layout.addLayout(self.button_layout)

    开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:19,

    示例3: __init__

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self):

    super(ButtonAndLongProcess, self).__init__()

    self.button = QPushButton("button")

    self.button.clicked.connect(self.buttonClicked)

    self.label = QLabel("label: before clicked")

    layout = QVBoxLayout()

    layout.addWidget(self.button)

    layout.addWidget(self.label)

    self.setLayout(layout)

    self.long_process_thread = LongProcessThread()

    self.long_process_thread.transaction.connect(self.afterLongProcess)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:18,

    示例4: __init__

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self):

    super(ButtonWithSizePolicy, self).__init__()

    button1 = QPushButton("button default")

    button2 = QPushButton("button maximum")

    button2.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)

    button3 = QPushButton("button preferred")

    button3.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

    button4 = QPushButton("button expanding")

    button4.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

    button5 = QPushButton("button minimum")

    button5.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

    button6 = QPushButton("button minimum expanding")

    button6.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)

    layout = QVBoxLayout()

    layout.addWidget(button1)

    layout.addWidget(button2)

    layout.addWidget(button3)

    layout.addWidget(button4)

    layout.addWidget(button5)

    layout.addWidget(button6)

    self.setLayout(layout)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:26,

    示例5: createTweetsGroupBox

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def createTweetsGroupBox(self):

    self.tweets_group_box = QtWidgets.QGroupBox("Tweets")

    self.account_address = QtWidgets.QLineEdit()

    self.fetch_button = QtWidgets.QPushButton("Fetch")

    self.add_to_bookmark_button = QtWidgets.QPushButton("Bookmark it!")

    self.connect(self.fetch_button, QtCore.SIGNAL('clicked()'), self.fetchTweets)

    self.connect(self.add_to_bookmark_button, QtCore.SIGNAL('clicked()'), self.bookmarkAddress)

    account_address_layout = QtWidgets.QHBoxLayout()

    account_address_layout.addWidget(self.account_address)

    account_address_layout.addWidget(self.fetch_button)

    account_address_layout.addWidget(self.add_to_bookmark_button)

    self.tweets_layout = QtWidgets.QVBoxLayout()

    self.tweets_main_layout = QtWidgets.QVBoxLayout()

    self.tweets_main_layout.addWidget(QtWidgets.QLabel("Address:"))

    self.tweets_main_layout.addLayout(account_address_layout)

    self.tweets_main_layout.addSpacing(20)

    self.tweets_main_layout.addLayout(self.tweets_layout)

    self.tweets_group_box.setLayout(self.tweets_main_layout)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:24,

    示例6: setupUi

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def setupUi(self, Form):

    Form.setObjectName("Form")

    Form.resize(300, 150)

    self.verticalLayout = QtWidgets.QVBoxLayout(Form)

    self.verticalLayout.setObjectName("verticalLayout")

    self.btnCreateSphere = QtWidgets.QPushButton(Form)

    self.btnCreateSphere.setObjectName("btnCreateSphere")

    self.verticalLayout.addWidget(self.btnCreateSphere)

    self.btnCallCppPlugin = QtWidgets.QPushButton(Form)

    self.btnCallCppPlugin.setObjectName("btnCallCppPlugin")

    self.verticalLayout.addWidget(self.btnCallCppPlugin)

    self.btnCallCSPlugin = QtWidgets.QPushButton(Form)

    self.btnCallCSPlugin.setObjectName("btnCallCSPlugin")

    self.verticalLayout.addWidget(self.btnCallCSPlugin)

    self.retranslateUi(Form)

    QtCore.QMetaObject.connectSlotsByName(Form)

    开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:19,

    示例7: setLang

    ​点赞 6

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def setLang(self, langName):

    uiList_lang_read = self.memoData['lang'][langName]

    for ui_name in uiList_lang_read:

    ui_element = self.uiList[ui_name]

    if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:

    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox

    if uiList_lang_read[ui_name] != "":

    ui_element.setText(uiList_lang_read[ui_name])

    elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:

    # uiType: QMenu, QGroupBox

    if uiList_lang_read[ui_name] != "":

    ui_element.setTitle(uiList_lang_read[ui_name])

    elif type(ui_element) in [ QtWidgets.QTabWidget]:

    # uiType: QTabWidget

    tabCnt = ui_element.count()

    if uiList_lang_read[ui_name] != "":

    tabNameList = uiList_lang_read[ui_name].split(';')

    if len(tabNameList) == tabCnt:

    for i in range(tabCnt):

    if tabNameList[i] != "":

    ui_element.setTabText(i,tabNameList[i])

    elif type(ui_element) == str:

    # uiType: string for msg

    if uiList_lang_read[ui_name] != "":

    self.uiList[ui_name] = uiList_lang_read[ui_name]

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:27,

    示例8: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, hexacolor, parent=None):

    super(ColorDialog, self).__init__(parent)

    self.setWindowFlags(QtCore.Qt.FramelessWindowHint)

    self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

    self.colorwheel = ColorWheel()

    self.colorwheel.set_current_color(QtGui.QColor(hexacolor))

    self.ok = QtWidgets.QPushButton('ok')

    self.ok.released.connect(self.accept)

    self.layout = QtWidgets.QVBoxLayout(self)

    self.layout.setContentsMargins(0, 0, 0, 0)

    self.layout.setSpacing(0)

    self.layout.addWidget(self.colorwheel)

    self.layout.addWidget(self.ok)

    开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:16,

    示例9: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self):

    super(ButtonAndLabel, self).__init__()

    self.button = QPushButton("button")

    self.button.clicked.connect(self.buttonClicked)

    self.label = QLabel("label: before clicked")

    layout = QVBoxLayout()

    layout.addWidget(self.button)

    layout.addWidget(self.label)

    self.setLayout(layout)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:15,

    示例10: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self):

    super(ButtonAndDialog, self).__init__()

    self.button = QPushButton("button")

    self.button.clicked.connect(self.buttonClicked)

    self.label = QLabel("")

    layout = QVBoxLayout()

    layout.addWidget(self.button)

    layout.addWidget(self.label)

    self.setLayout(layout)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:15,

    示例11: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self):

    super(ButtonAndList, self).__init__()

    self.button = QPushButton("button")

    self.button.clicked.connect(self.buttonClicked)

    self.v_layout = QVBoxLayout()

    layout = QVBoxLayout()

    layout.addWidget(self.button)

    layout.addLayout(self.v_layout)

    self.setLayout(layout)

    开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:15,

    示例12: setupUi

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def setupUi(self, Form):

    Form.setObjectName("Form")

    Form.resize(360, 180)

    self.gridLayout = QtWidgets.QGridLayout(Form)

    self.gridLayout.setObjectName("gridLayout")

    self.label_2 = QtWidgets.QLabel(Form)

    self.label_2.setObjectName("label_2")

    self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)

    self.cbObjType = QtWidgets.QComboBox(Form)

    self.cbObjType.setObjectName("cbObjType")

    self.cbObjType.addItem("")

    self.cbObjType.addItem("")

    self.gridLayout.addWidget(self.cbObjType, 0, 1, 1, 1)

    self.btnCreate = QtWidgets.QPushButton(Form)

    self.btnCreate.setObjectName("btnCreate")

    self.gridLayout.addWidget(self.btnCreate, 0, 2, 1, 1)

    self.label = QtWidgets.QLabel(Form)

    self.label.setObjectName("label")

    self.gridLayout.addWidget(self.label, 1, 0, 1, 1)

    self.leNewName = QtWidgets.QLineEdit(Form)

    self.leNewName.setObjectName("leNewName")

    self.gridLayout.addWidget(self.leNewName, 1, 1, 1, 1)

    self.btnRename = QtWidgets.QPushButton(Form)

    self.btnRename.setObjectName("btnRename")

    self.gridLayout.addWidget(self.btnRename, 1, 2, 1, 1)

    self.retranslateUi(Form)

    QtCore.QMetaObject.connectSlotsByName(Form)

    开发者ID:WendyAndAndy,项目名称:MayaDev,代码行数:30,

    示例13: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, node):

    super().__init__()

    self.node: NetworkNode = node

    self.delete_popup = None

    self.layout = QGridLayout()

    self.table = QTableWidget(0, 3)

    self.table.setHorizontalHeaderLabels(['Id', 'Key', 'Value'])

    self.table.setColumnHidden(0, True)

    self.node.configuration.configuration_changed.connect(

    self.handle_configuration_change

    )

    self.table.cellChanged.connect(self.handle_cell_change)

    self.layout.addWidget(self.table, 0, 0, 1, 2)

    self.deleteButton = QPushButton('Remove Selected Row')

    self.deleteButton.clicked.connect(

    self.handle_delete_action

    )

    self.layout.addWidget(self.deleteButton, 1, 0)

    self.addButton = QPushButton('Add Configuration')

    self.addButton.clicked.connect(

    self.handle_add_action

    )

    self.layout.addWidget(self.addButton, 1, 1)

    self.setLayout(self.layout)

    #################################

    # Add/Update/Get for table rows #

    #################################

    开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:41,

    示例14: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, button_text: str, copy_text: str):

    super(CopyButton, self).__init__()

    self.copy_text = copy_text

    self.button_text = button_text

    self.button = QPushButton(button_text)

    # noinspection PyUnresolvedReferences

    self.button.clicked.connect(self.copy)

    self.addWidget(self.button)

    self.timer = QTimer(self.parentWidget())

    开发者ID:lightning-power-users,项目名称:node-launcher,代码行数:11,

    示例15: itemAeropython

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def itemAeropython(self):

    form = QtWidgets.QFormLayout()

    label1 = QtWidgets.QLabel(u'Angle of attack (°)')

    self.aoa = QtWidgets.QDoubleSpinBox()

    self.aoa.setSingleStep(0.1)

    self.aoa.setDecimals(1)

    self.aoa.setRange(-10.0, 10.0)

    self.aoa.setValue(0.0)

    form.addRow(label1, self.aoa)

    label2 = QtWidgets.QLabel('Freestream velocity (m/s)')

    self.freestream = QtWidgets.QDoubleSpinBox()

    self.freestream.setSingleStep(0.1)

    self.freestream.setDecimals(2)

    self.freestream.setRange(0.0, 100.0)

    self.freestream.setValue(10.0)

    form.addRow(label2, self.freestream)

    label3 = QtWidgets.QLabel('Number of panels (-)')

    self.panels = QtWidgets.QSpinBox()

    self.panels.setRange(10, 500)

    self.panels.setValue(40)

    form.addRow(label3, self.panels)

    panelMethodButton = QtWidgets.QPushButton('Calculate lift coefficient')

    form.addRow(panelMethodButton)

    self.item_ap = QtWidgets.QGroupBox('AeroPython Panel Method')

    self.item_ap.setLayout(form)

    panelMethodButton.clicked.connect(self.runPanelMethod)

    开发者ID:chiefenne,项目名称:PyAero,代码行数:35,

    示例16: itemContourAnalysis

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def itemContourAnalysis(self):

    box = QtWidgets.QVBoxLayout()

    vlayout = QtWidgets.QVBoxLayout()

    gb = QtWidgets.QGroupBox('Select contour to analyze')

    self.b1 = QtWidgets.QRadioButton('Original')

    self.b2 = QtWidgets.QRadioButton('Refined')

    self.b2.setChecked(True)

    vlayout.addWidget(self.b1)

    vlayout.addWidget(self.b2)

    gb.setLayout(vlayout)

    box.addWidget(gb)

    vlayout = QtWidgets.QVBoxLayout()

    self.cgb = QtWidgets.QGroupBox('Select plot quantity')

    self.cpb1 = QtWidgets.QRadioButton('Gradient')

    self.cpb2 = QtWidgets.QRadioButton('Curvature')

    self.cpb3 = QtWidgets.QRadioButton('Radius of Curvature')

    self.cpb1.setChecked(True)

    vlayout.addWidget(self.cpb1)

    vlayout.addWidget(self.cpb2)

    vlayout.addWidget(self.cpb3)

    self.cgb.setLayout(vlayout)

    self.cgb.setEnabled(False)

    box.addWidget(self.cgb)

    analyzeButton = QtWidgets.QPushButton('Analyze Contour')

    analyzeButton.setGeometry(10, 10, 200, 50)

    box.addWidget(analyzeButton)

    box.addStretch(1)

    self.item_ca = QtWidgets.QWidget()

    self.item_ca.setLayout(box)

    analyzeButton.clicked.connect(self.analyzeAirfoil)

    开发者ID:chiefenne,项目名称:PyAero,代码行数:39,

    示例17: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, remotePath: str, targetPath: str, isMultipleDownload: bool, parent: QObject):

    super().__init__(parent, Qt.CustomizeWindowHint | Qt.WindowTitleHint)

    self.titleLabel = QLabel(f"Downloading {remotePath} to {targetPath}")

    self.progressBar = QProgressBar()

    self.progressBar.setMinimum(0)

    self.progressBar.setMaximum(0)

    self.actualProgress = 0

    self.actualMaximum = 0

    self.isComplete = False

    self.isMultipleDownload = isMultipleDownload

    self.downloadCount = 0

    self.downloadTotal = 0

    self.progressLabel = QLabel(f"{self.downloadCount} / {self.downloadTotal} files downloaded")

    self.progressSizeLabel = QLabel("0 bytes")

    self.widgetLayout = QVBoxLayout()

    self.widgetLayout.addWidget(self.titleLabel)

    self.widgetLayout.addWidget(self.progressLabel)

    self.widgetLayout.addWidget(self.progressBar)

    self.widgetLayout.addWidget(self.progressSizeLabel)

    self.closeButton = QPushButton("Continue download in background")

    self.closeButton.clicked.connect(self.hide)

    self.widgetLayout.addWidget(self.closeButton)

    self.setLayout(self.widgetLayout)

    开发者ID:GoSecure,项目名称:pyrdp,代码行数:33,

    示例18: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__ (self, parent):

    QtWidgets.QDialog.__init__(self, parent)

    self.setWindowTitle("Export depth maps")

    self.btnQuit = QtWidgets.QPushButton("&Close")

    self.btnP1 = QtWidgets.QPushButton("&Export")

    self.pBar = QtWidgets.QProgressBar()

    self.pBar.setTextVisible(False)

    # self.selTxt =QtWidgets.QLabel()

    # self.selTxt.setText("Apply to:")

    self.radioBtn_all = QtWidgets.QRadioButton("Apply to all cameras")

    self.radioBtn_sel = QtWidgets.QRadioButton("Apply to selected")

    self.radioBtn_all.setChecked(True)

    self.radioBtn_sel.setChecked(False)

    self.formTxt = QtWidgets.QLabel()

    self.formTxt.setText("Export format:")

    self.formCmb = QtWidgets.QComboBox()

    self.formCmb.addItem("1-band F32")

    self.formCmb.addItem("Grayscale 8-bit")

    self.formCmb.addItem("Grayscale 16-bit")

    # creating layout

    layout = QtWidgets.QGridLayout()

    layout.setSpacing(10)

    layout.addWidget(self.radioBtn_all, 0, 0)

    layout.addWidget(self.radioBtn_sel, 1, 0)

    layout.addWidget(self.formTxt, 0, 1)

    layout.addWidget(self.formCmb, 1, 1)

    layout.addWidget(self.btnP1, 2, 0)

    layout.addWidget(self.btnQuit, 2, 1)

    layout.addWidget(self.pBar, 3, 0, 1, 2)

    self.setLayout(layout)

    QtCore.QObject.connect(self.btnP1, QtCore.SIGNAL("clicked()"), self.export_depth)

    QtCore.QObject.connect(self.btnQuit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))

    self.exec()

    开发者ID:agisoft-llc,项目名称:metashape-scripts,代码行数:41,

    示例19: __init__

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def __init__(self, parent):

    QtWidgets.QDialog.__init__(self, parent)

    self.setWindowTitle("Copy bounding box")

    self.labelFrom = QtWidgets.QLabel("From")

    self.labelTo = QtWidgets.QLabel("To")

    self.fromChunk = QtWidgets.QComboBox()

    for chunk in Metashape.app.document.chunks:

    self.fromChunk.addItem(chunk.label)

    self.toChunks = QtWidgets.QListWidget()

    self.toChunks.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)

    for chunk in Metashape.app.document.chunks:

    self.toChunks.addItem(chunk.label)

    self.btnOk = QtWidgets.QPushButton("Ok")

    self.btnOk.setFixedSize(90, 50)

    self.btnOk.setToolTip("Copy bounding box to all selected chunks")

    self.btnQuit = QtWidgets.QPushButton("Close")

    self.btnQuit.setFixedSize(90, 50)

    layout = QtWidgets.QGridLayout() # creating layout

    layout.addWidget(self.labelFrom, 0, 0)

    layout.addWidget(self.fromChunk, 0, 1)

    layout.addWidget(self.labelTo, 0, 2)

    layout.addWidget(self.toChunks, 0, 3)

    layout.addWidget(self.btnOk, 1, 1)

    layout.addWidget(self.btnQuit, 1, 3)

    self.setLayout(layout)

    QtCore.QObject.connect(self.btnOk, QtCore.SIGNAL("clicked()"), self.copyBoundingBox)

    QtCore.QObject.connect(self.btnQuit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))

    self.exec()

    开发者ID:agisoft-llc,项目名称:metashape-scripts,代码行数:42,

    示例20: fontNormal_action

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def fontNormal_action(self, uiClass_list=[]):

    if len(uiClass_list) == 0:

    uiClass_list = 'QLabel,QPushButton'.split(',')

    self.memoData['font_size'] = self.memoData['font_size_default']

    self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:7,

    示例21: fontUp_action

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def fontUp_action(self, uiClass_list=[]):

    if len(uiClass_list) == 0:

    uiClass_list = 'QLabel,QPushButton'.split(',')

    self.memoData['font_size'] += 2

    self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:7,

    示例22: fontDown_action

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def fontDown_action(self, uiClass_list=[]):

    if len(uiClass_list) == 0:

    uiClass_list = 'QLabel,QPushButton'.split(',')

    if self.memoData['font_size'] >= self.memoData['font_size_default']:

    self.memoData['font_size'] -= 2

    self.setStyleSheet( "{0} { font-size: {1}pt;}".format(','.join(uiClass_list), self.memoData['font_size']) )

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:8,

    示例23: setLang

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def setLang(self, langName):

    lang_data = self.memoData['lang'][langName]

    for ui_name in lang_data.keys():

    if ui_name in self.uiList.keys() and lang_data[ui_name] != '':

    ui_element = self.uiList[ui_name]

    # '' means no translation availdanle in that data file

    if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):

    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox

    ui_element.setText(lang_data[ui_name])

    elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):

    # uiType: QMenu, QGroupBox

    ui_element.setTitle(lang_data[ui_name])

    elif isinstance(ui_element, QtWidgets.QTabWidget):

    # uiType: QTabWidget

    tabCnt = ui_element.count()

    tabNameList = lang_data[ui_name].split(';')

    if len(tabNameList) == tabCnt:

    for i in range(tabCnt):

    if tabNameList[i] != '':

    ui_element.setTabText(i,tabNameList[i])

    elif isinstance(ui_element, QtWidgets.QComboBox):

    # uiType: QComboBox

    itemCnt = ui_element.count()

    itemNameList = lang_data[ui_name].split(';')

    ui_element.clear()

    ui_element.addItems(itemNameList)

    elif isinstance(ui_element, QtWidgets.QTreeWidget):

    # uiType: QTreeWidget

    labelCnt = ui_element.headerItem().columnCount()

    labelList = lang_data[ui_name].split(';')

    ui_element.setHeaderLabels(labelList)

    elif isinstance(ui_element, QtWidgets.QTableWidget):

    # uiType: QTableWidget

    colCnt = ui_element.columnCount()

    headerList = lang_data[ui_name].split(';')

    cur_table.setHorizontalHeaderLabels( headerList )

    elif isinstance(ui_element, (str, unicode) ):

    # uiType: string for msg

    self.uiList[ui_name] = lang_data[ui_name]

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:41,

    示例24: fontNormal_action

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def fontNormal_action(self):

    self.memoData['font_size'] = self.memoData['font_size_default']

    self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:5,

    示例25: fontUp_action

    ​点赞 5

    # 需要导入模块: from PySide2 import QtWidgets [as 别名]

    # 或者: from PySide2.QtWidgets import QPushButton [as 别名]

    def fontUp_action(self):

    self.memoData['font_size'] += 2

    self.setStyleSheet("QLabel,QPushButton { font-size: %dpt;}" % self.memoData['font_size'])

    开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:5,

    注:本文中的PySide2.QtWidgets.QPushButton方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

    展开全文
  • 谁有rails的widgets插件

    2009-03-04 21:33:24
    怎么也下不下来这个控件(就是有tabnav的那个),找到两个下载方法(以前的地址不能了) 1. ruby script/plugin install http://rails-widgets.googlecode.com/svn/widgets 我的系统室windows,这个下不了,...
  • Advanced Widgets :Using GIndexGroup and GindexCombo在这个教程中我们将会建立一个叫做GINDEXAPP的简单工程来展示怎么用GIndexGroup和GIndexCombo。我们假设你已经了解前文中APP开发的过程。 GindexGroup可以让你...

    Advanced Widgets :Using GIndexGroup and GindexCombo


    在这个教程中我们将会建立一个叫做GINDEXAPP的简单工程来展示怎么用GIndexGroup和GIndexCombo。我们假设你已经了解前文中APP开发的过程。
    GindexGroup可以让你给窗体部件归类,GIndexCombo就像一个指针让你可以在不同的GindexGroup中切换来减少窗体的占用面积和在生成APP GUI时占用更少的资源来使APP的运行效果更佳。
    在下面的图中你可以比较普通的布置方案和用GindexGroup的不同。如果在这个例子里你只有5个相似的部件,或许你想同时显示它们,设想你如果有6个部件你就没有其余的空间来放置它,你只能把它们放在不同的Tab上,这不是一个好的解决方案。
    这里写图片描述


    尽管使用GIndexGroup和GIndexCombo 是进阶的教程,但它们不难。本质上,GIndexCombo就是GIndexGroup的选择器。
    当你创建一个GIndexGroup,你需要拖一个GIndexCombo且只有一个在窗体里,之后你可以拖任何你想要的窗体部件进去。然后你就能马上得到GIndexCombo的最多能产生的数目。保存后,你将在manifest文件中看到一个.wg文件。

    这里写图片描述
    这个新的文件包含了你刚刚加入的窗体部件:

    import ifx.davex.app.manifest.*;
    
    class Gindexgroup_example {
      public GCombo gcombo_example;
      public GInteger ginteger_example;
      public GCheck gcheck_example;
    
      public Gindexgroup_example (DaveEnv daveEnv, String widgetName, int index){
        gcombo_example = new GCombo(widgetName:"gcombo_example", options:["Option 1","Option 2"], value:"Option 1", enabled:true, visible:true, isMandatoryValue:false , parentWidgetName:widgetName)
        ginteger_example = new GInteger(widgetName:"ginteger_example", value:1024, minValue:0, maxValue:4096, enabled:true, visible:true, isMandatoryValue:false , parentWidgetName:widgetName)
        gcheck_example = new GCheck(widgetName:"gcheck_example", value:false, enabled:true, visible:true, parentWidgetName:widgetName)
      }
    }
    

    在此同时,一些新的代码在GINDEXAPP_GUI.manifest文件中生成:

    abstract class GINDEXAPP_GUI extends AppManifest {
      // Begin : UI variable section
      public GInteger ginteger_number_of_items;
      public GIndexCombo gindexcombo_item;
      public GIndexGroup gindexgroup_example;
      public RArray<Gindexgroup_example> rArraygindexgroup_example = RArray(16);
    
    
      public GINDEXAPP_GUI(DaveEnv daveEnv){
    
        ginteger_number_of_items = GInteger(widgetName:"ginteger_number_of_items", value:5, minValue:1, maxValue:16, enabled:true, visible:true, isMandatoryValue:false)
        gindexcombo_item = GIndexCombo(widgetName:"gindexcombo_item", options:["ITEM_0","ITEM_1","ITEM_2","ITEM_3","ITEM_4","ITEM_5","ITEM_6","ITEM_7","ITEM_8","ITEM_9","ITEM_10","ITEM_11","ITEM_12","ITEM_13","ITEM_14","ITEM_15"], value:"ITEM_0")
        gindexgroup_example = GIndexGroup(widgetName:"gindexgroup_example", text:"GIndexGroup", enabled:true, visible:true, gIndexCombo:gindexcombo_item, rArray:rArraygindexgroup_example)
        for(int i=0; i<16; i++){
          rArraygindexgroup_example[i] = new Gindexgroup_example(daveEnv, "gindexgroup_example", i)
        }
    
      }
      // End : UI variable section
    }
    

    在这个例子中,我们最多允许了16个部件(组),但我们只显示5组。这是因为我们定义GIndexCombo.maxChoices = 16,然后一个新的RArry对象被定义为16,定义了包含了所有可能的GIndexGroup窗体部件。最大可以选择的数目必须和GInteger中定义的maxChoices数目一致:
    这里写图片描述
    在这里,我们有一个RArry对象包含了每一个GIndexGroup,有了GIndexCombo我们可以通过GUI选择显示GIndexGroup。在下面的图中你可以看到上面例子展示的原理图:
    这里写图片描述
    你可以更改显示数量的多少,但你不能更改选择的数量,因为它是固定的。为了改变显示的数量,你可以通过定义GIndexCombo.options来实现。需要注意List必须和RArray size拥有相当的长度,你可以在manifest中如下定义:

    gindexcombo_item.options = MF(
      {
        List<String> l = new ArrayList(rArraygindexgroup_example.size())
        for (int i = 0; i < ginteger_number_of_items.value; i++)
        {
          l.add("ITEM_$i".toString())
        }
        l
      },
      List
    )
    

    在下面的程序中,我们建立了一列String 元素,我们把non-null放入相应的String元素,当用户通过在APP GUI的GInteger 在ginteger_number_of_items放入数值。其余的值为null,它们将不会在GIndexCombo显示。
    这里写图片描述
    就像你看到的,GindexGroup的元素也将会继续在RArry中显示,但它们不在窗体中可见,因为它们在gindexcombo_item.options 列表中对应空值。

    你可以用这部件去定义信号,占用资源或生成代码。在下面的代码中你可以看到一些Templates的例子,它们使用了GIndexGroup窗体部件的返回值生成代码:

    gindexapp.h file:
    #ifndef _GINDEXAPP_H_
    #define _GINDEXAPP_H_
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /***********************************************************************************************************************
    ** System Header file inclusion **
    ***********************************************************************************************************************/
    #include <DAVE.h>
    
    /***********************************************************************************************************************
    ** Macros **
    ***********************************************************************************************************************/
    
    /***********************************************************************************************************************
    ** Data types (typedefs and enumerations) **
    ***********************************************************************************************************************/
    typedef enum GINDEXAPP_STATUS
    {
      GINDEXAPP_STATUS_OK = 0U, // 0 = Status OK
      GINDEXAPP_STATUS_FAILURE = 1U // 1 = Status Failed
    } GINDEXAPP_STATUS_t;
    
    /***********************************************************************************************************************
    ** Data structures **
    ***********************************************************************************************************************/
    typedef struct GINDEXAPP {
      char * gcombo;
      int ginteger;
      bool gcheck;
    } GINDEXAPP_t;
    
    /***********************************************************************************************************************
    ** API prototypes **
    ***********************************************************************************************************************/
    
    
    #include "GINDEXAPP_extern.h" /* Included to access the APP Handles at Main.c */
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* GINDEXAPP_H_ */
    
    
    gindexapp_extern_h.tmpl file:
    
     out.print("""
    #ifndef GINDEXAPP_EXTERN_H_
    #define GINDEXAPP_EXTERN_H_
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /* Extern declaration of GINDEXAPP APP handlers */
    """)
    for(def app : appInstancesList){
    
      for (int i = 0; i < app.ginteger_number_of_items.value; i++)
      {
        out.print("""
        extern GINDEXAPP_t ${app.getInstanceLabel()}_ITEM_$i;""") 
      }
    }
    
    out.print("""
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* GINDEXAPP_EXTERN_H_ */""")
    
    
    
    gindexapp_conf_c.tmpl file:
    out.println("#include \"gindexapp.h\"")
    for (GINDEXAPP app : appInstancesList)
    {
      for (int i = 0; i < app.ginteger_number_of_items.value; i++)
      {
    out.print("""
    GINDEXAPP_t ${app.getInstanceLabel()}_ITEM_$i =
    {
      .gcombo = "${app.rArraygindexgroup_example[i].gcombo_example.value}",
      .ginteger = ${app.rArraygindexgroup_example[i].ginteger_example.value},
      .gcheck = ${app.rArraygindexgroup_example[i].gcheck_example.value ? "true" : "false"}
    };
    """)
      }
    }
    
    

    下图你可以看到这个例子在运行在DAVE™ 4中的样子:这里写图片描述

    它所生成的代码:

    gindexapp_extern.h file:
    
    #ifndef GINDEXAPP_EXTERN_H_
    #define GINDEXAPP_EXTERN_H_
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /* Extern declaration of GINDEXAPP APP handlers */
    
    extern GINDEXAPP_t GINDEXAPP_0_ITEM_0;
    extern GINDEXAPP_t GINDEXAPP_0_ITEM_1;
    extern GINDEXAPP_t GINDEXAPP_1_ITEM_0;
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* GINDEXAPP_EXTERN_H_ */
    
    
    gindexapp_conf.c file:
    
    #include "gindexapp.h"
    
    GINDEXAPP_t GINDEXAPP_0_ITEM_0 =
    {
      .gcombo = "Option 1",
      .ginteger = 3210,
      .gcheck = true
    };
    
    GINDEXAPP_t GINDEXAPP_0_ITEM_1 =
    {
      .gcombo = "Option 1",
      .ginteger = 1024,
      .gcheck = false
    };
    
    GINDEXAPP_t GINDEXAPP_1_ITEM_0 =
    {
      .gcombo = "Option 2",
      .ginteger = 83,
      .gcheck = false
    };
    
    
    展开全文
  • Qt on Android:让 Qt Widgets 和 Qt Quick 应用全屏显示

    万次阅读 热门讨论 2014-07-29 13:26:36
    Android 系统版本很多,较新的 4.4 ,较老的 2.3 ,都有人。 Qt on Android 开发的 Android 应用,默认在 Android 设备上是非全屏的。而有些应用的需求是全屏显示,比如游戏。那么怎么样才能做到这点呢?

        Android 系统版本很多,较新的 4.4 ,较老的 2.3 ,都有人用。 Qt on Android 开发的 Android 应用,默认在 Android 设备上是非全屏的。而有些应用的需求是全屏显示,比如游戏。那么怎么样才能做到这点呢?

        我们需要分 Android 系统版本来说。

    Android 2.x

        对于 4.0 以前,比如 2.2 、 2.3 的系统,可以修改 AndroidManifest.xml 文件来实现全屏。

        首先需要为 Qt on Android 应用生成一个 AndroidManifest.xml 文件,具体参考《 Qt on Android:图文详解Hello World全过程》一文。创建 AndroidManifest.xml 的示意图如下:


        点击上图中标号为 7 的那个按钮即可创建一个 AndroidManifest.xml 文件。该文件默认生成在 Qt 项目目录下的 android 子目录内。

        然后需要打开 AndroidManifest.xml 文件,找到 Activity 标签,为其加入下面这个属性:

    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

        注意和前、后的其它属性之间留空格。

        在 2.x 系统上运行你的 Qt on Android 应用吧,已经全屏了,连标题栏都没有了。

    Android 4.x

        Android 系统版本到了 4.0 以后,前面那种设置活动主题的方式无效了。我们需要在 Java 代码中为 Activity 设置一个全屏的窗口标记。

        这在 Java 撰写的 Android 应用上很简单,只需要在 Activity 的 onCreate() 方法中加入下面的代码:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        可是到了 Qt on Android 应用,就稍微有些复杂了。

        一步一步说吧,这次以我们的 Qt Quick App 为例来说明,先参考《Qt Quick 之 Hello World 图文详解》一文创建一个项目,我演示需要,还是以 HelloQtQuickApp 为基础修改的。

        先看下修改前的效果图(我在 4.0.3 系统的机顶盒上运行):


        注意到图片下方的状态栏了吧。

    生成 AndroidManifest.xml 

         参考上一节吧,把 Activity 的 Theme 属性也设置一下。

    为 Qt 项目添加 Java 文件

        话说 Qt on Android 应用, Qt 部分的代码以 JNI 的方式经由 Java 代码启动的。为了能够启动 Qt 代码,进入 Qt 的世界, Qt 框架提供了 QPA 层以及必要的 Activity 、 Application 实现。详情参考《Qt on Android Episode 1(翻译)》和《Qt for Android 部署流程分析》两篇文章。

        这里以 Qt 5.2.0 为例来作一简单说明。

    QtActivity 简析

        如果你观察 AndroidManifest.xml 文件,会发现里面的 Activity 标签,指定的 activity 名字是:"org.qtproject.qt5.android.bindings.QtActivity" 。没错,就是它!它是由 Qt 框架提供的,你 Qt on Android 应用的入口。 QtActivity 的位置在这里:

    c:\qt\Qt5.2.0\5.2.0\android_armv5\src\android\java\src\org\qtproject\qt5\android\bindings\QtActivity.java

        感兴趣的可以打开这个 Java 文件研究一下。

        下面是 QtActivity.java 的 onCreate 函数的摘录:

    ...
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            try {
                setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null));
            } catch (Exception e) {
                e.printStackTrace();
            }
    
            if (Build.VERSION.SDK_INT > 10) {
                try {
                    requestWindowFeature(Window.class.getField("FEATURE_ACTION_BAR").getInt(null));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                requestWindowFeature(Window.FEATURE_NO_TITLE);
            }
        ...
        }
    ...

        如你所见, QtActivity 区分了 SDK 版本, 10 以上的请求 FEATURE_ACTION_BAR 特性, 10 以下(Android 2.3及以下)的版本不要 title (太难看了,只显示应用名字,木啥用)。

        你懂的,  Qt Creator 可以编译 Java 源码(通过调用 Ant ), QtActivity 就是这样编译到你的 APK 中的。所以,我们也可以添加自己的 Java 代码喽。

        我们要添加全屏标记,需要继承 QtActivity 类来实现一个新的 Activity 。当然如果你想粗暴地解决这个问题,可以直接修改 QtActivity.java ,直接加一行代码即可。什么代码?看下面。

    实现QtFullscreenActivity

        QtFullscreenActivity 继承自 QtActivity 类,代码非常简单。如下:

    package an.qt.helloQtQuickApp;
    import android.content.Context;
    import android.content.Intent;
    import android.app.PendingIntent;
    import android.util.Log;
    import android.os.Bundle;
    import android.view.WindowManager;
    
    public class QtFullscreenActivity extends org.qtproject.qt5.android.bindings.QtActivity
    {
        private final static String TAG = "QtFullscreen";
        @Override
        public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }
    

        上面代码中 "getWindow()" 起始的那行,就是设置全屏标记的。

    添加 QtFullscreenActivity 到 pro 文件

        我把 QtFullscreenActivity.java 文件放在了 android/src/an/qt/helloQtQuickApp/ 下面,所以 pro 文件中相关的部分是酱紫的:

    OTHER_FILES += \
        android/AndroidManifest.xml \
        android/src/an/qt/helloQtQuickApp/QtFullscreenActivity.java

        需要注意的是, Java 代码中的包名(QtFullscreenActivity第一行),和路径是严格匹配的, Java类名则和源代码文件名严格匹配。

        然后你可以看到下面的项目视图了:



    修改 AndroidManifest.xml 

        这是改动的最后一步了。

        我们实现的 Activity 名字是 QtFullscreenActivity ,所以呢, AndroidManifest.xml 文件中也要修改,保持一致。见下面:

    <?xml version='1.0' encoding='utf-8'?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        android:versionCode="1" 
        android:installLocation="auto" 
        package="an.qt.helloQtQuickApp" 
        android:versionName="1.0">
        <application 
            android:name="org.qtproject.qt5.android.bindings.QtApplication" 
            android:label="@string/app_name">
            <activity 
                android:name="an.qt.helloQtQuickApp.QtFullscreenActivity" 
                android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" 
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
                android:label="@string/app_name" 
                android:screenOrientation="unspecified">
                <intent-filter>
    ...
    </manifest>


        好啦,到此为止,全部改动就绪。运行我们的 HelloQtQuickApp 吧。

        下面是现在运行的效果:



        好啦,到此结束。    

        本系列的其他文章:


    展开全文
  •  关于yii的bootstrap插件,虽然官网上有api文档,个人总觉得不是很详尽,很多细节的地方仍然搞不清楚怎么用,只好一点一点去试,这不,今天又碰到一问题。需求是这样的,我想在bootstrap.widgets.TbMenu生成的menu...
  • Qt Widgets、QML、Qt Quick的区别

    千次阅读 2019-10-08 21:27:24
    最近一段时间接触了QML,并了解了C++如何与QML实现数据交互后,我在QWidget中如何去加载QML时看到了QQuickView,QQuickWIdget,把Qt Quick 与 QML一时之间没怎么弄明白。 区别 参考这位大神博客: ...
  • 我的终极整理,供参考# coding:utf-8import matplotlib# 使用 matplotlib中的FigureCanvas (在使用 Qt5 Backends中 FigureCanvas继承自QtWidgets.QWidget)from matplotlib.backends.backend_qt5agg import ...
  • 这个插件在功能上来说是比较强大的了,但用起来却比较简单,对想做拖动布局的...闲话少说,还是看看怎么用吧! 首先当然是引入相关的js文件: jquery.min.jsjq框架 jquery-ui.min.js jq的ui jquery.easywidgets....
  • 数据类型数据类型用于指定数据元素的大小以及如何解释数据。每个指令参数至少支持一种数据类型,而...实参指的是包含指令要使用的数据的存储单元(含“%”字符前缀)或常量(例如,%MD400"Number_of_Widgets")。用户指...
  • jQuery Mobile里都有什么控件? ...jQuery Mobile里slider控件的change事件怎么玩? slider控件有slider图标和可输入input两部份组成 http://api.jquerymobile.com/slider/#event-stop ...
  • 我正在尝试创建具有三个参数变化...基本上,我想重新创建下面的规范示例,在该示例中,我希望使用文本框(而不是滑块)在其中输入参数import numpy as npimport matplotlib.pyplot as pltfrom matplotlib.widgets import...
  • from PyQt5 import QtCore, QtGui, QtWidgets class Ui_mainWindow(object): def setupUi(self, mainWindow): mainWindow.setObjectName("mainWindow") mainWindow.resize(796, 598) self.central...
  • 信号与槽有三种使用方法第一种:内置信号与槽的使用第二种:自定义信号与槽...这种也是我们前面的最多的,下面简单的一个实例,大家就会明白import sysfrom PyQt5.QtWidgets import QMessageBox,QPushButton,QApp...
  • from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_MainWindow(object):def setupUi(self, MainWindow):MainWindow.setObjectName("MainWindow")MainWindow.resize(472, 239)self.centralwidget = QtWi...
  • Gentelella-rtl on Yii framework 2 with an asset bundle, a layout template and some widgets. inspired from Gentelella on Yii framework 2 Gentelella by React Gentelella realized by React Let us know ...
  • PyQt5简单多线程信号与槽的使用最简单的多线程使用方法是利用QThread函数,展示QThread函数和信号简单结合的方法import sysfrom PyQt5.QtCore import *from PyQt5.QtWidgets import *class Main(QWidget):def __init...
  • Awesome Python A curated list of awesome Python frameworks, libraries, software and resources. ... Awesome Python Admin Panels Algorithms and Design Patterns ASGI Servers Asynchronous Programming ...
  • These widgets are incredibly common in our UIs; we've done the hard work figuring this out so you don't need to spend hours fixing and handling numerous edge cases that we already ran into while ...
  • dw打开defalut.html 里面的代码如下: 二、为底部帮助文章栏目增加rel="nofollow" 找到系统安装目录下的plugins\widgets目录下的treelist目录,打开widget_treelist.php找到    
  • Python中guiqwt是和MatPlotLib一样优秀的2D绘图库,基于PyQt库,里面有进行曲线数据拟合的专门工具guifit.guifit...起来十分简单,下面是示例程序:#-*- coding:utf-8 -*-import numpy as npfrom guiqwt.widgets.fit i...
  • from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QPushButton,QVBoxLayout,QHBoxLayout,QComboBox,QRadioButton,QLineEdit from PyQt5.QtGui import QMovie,QPixmap from PyQt5.QtCore import Qt,...
  • 我是这样做的,刚才我/QtSDK/Desktop/Qt/4.8.1/gcc/plugins/designer/designer设计器打开,看到了Qwt Widgets了,但是打开qt creator 还是没有,奇怪了 对我有用[0] 丢个板砖[0] 引用 | ...
  • UI做出来了一个计算器,按键也都设置好了,什么布局都弄好了,然后再文件夹里新建一个文件,引用UI,想弹出一个计算器来,但点击弹出来的计算器就会could not convert string to float这个错误 代码:# 系统包 ...
  • Orchard(三):搞清来龙去脉(2)-Widgets 之前使用总结  这几天,我专门去了一下Orchard。有一些比较浅的体验:总的说来,Orchard使用起来可配置性好。  举个例子:想在网站上加入一个搜索引擎,只需要...

空空如也

空空如也

1 2 3 4
收藏数 66
精华内容 26
关键字:

widgets怎么用