当前位置: 首页>>代码示例>>Golang>>正文


Golang Driver.CallSync方法代码示例

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


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

示例1: appMain


//.........这里部分代码省略.........
		}
		downloadedCerts = append(downloadedCerts, cert)
		urlTextBox.SetText("")
		updateDownloadedCerts()
	}

	urlTextBox.OnTextChanged(func([]gxui.TextBoxEdit) {
		isEmpty := (urlTextBox.Text() == "")
		fetchButton.SetVisible(!isEmpty)
	})
	urlTextBox.OnKeyPress(func(event gxui.KeyboardEvent) {
		char := event.Key
		if char == gxui.KeyEnter || char == gxui.KeyKpEnter {
			isEmpty := (urlTextBox.Text() == "")
			if !isEmpty {
				downloadCert()
			}
		}
	})

	fetchButton.OnClick(func(gxui.MouseEvent) {
		downloadCert()
	})

	removeButton.OnClick(func(gxui.MouseEvent) {
		if uploading {
			return
		}
		selected := certList.Selected()
		i := certList.Adapter().ItemIndex(selected)
		downloadedCerts = append(downloadedCerts[:i], downloadedCerts[i+1:]...)
		updateDownloadedCerts()
		removeButton.SetVisible(false)
	})
	certList.OnSelectionChanged(func(gxui.AdapterItem) {
		removeButton.SetVisible(true)
	})
	removeButton.SetVisible(false)

	refreshPortList := func() {
		if uploading {
			return
		}
		if list, err := serial.GetPortsList(); err != nil {
			log.Println("Error fetching serial ports" + err.Error())
		} else {
			portListAdapter.SetItems(list)
		}
	}
	refreshPortList()

	refreshButton.OnClick(func(gxui.MouseEvent) {
		refreshPortList()
		portSelected = false
		updateUploadButton()
	})
	portList.OnSelectionChanged(func(gxui.AdapterItem) {
		portSelected = true
		updateUploadButton()
	})

	updateProgress := func(msg string, percent int) {
		time.Sleep(time.Second)
		driver.CallSync(func() {
			if percent == -1 {
				progressStatus.SetColor(gxui.Red)
				progressBar.SetVisible(false)
			} else if percent == 100 {
				progressStatus.SetColor(gxui.Green)
				progressBar.SetVisible(false)
			} else {
				progressStatus.SetColor(gxui.White)
				progressBar.SetProgress(percent)
				progressBar.SetVisible(true)
			}
			progressStatus.SetText(msg)
		})
	}
	progressBar.SetVisible(false)

	uploadButton.OnClick(func(gxui.MouseEvent) {
		if uploading {
			return
		}
		port := portList.Selected().(string)
		uploading = true
		go uploadCertificates(port, driver, updateProgress)
		log.Println(port)
	})

	updateDownloadedCerts()

	window := theme.CreateWindow(800, 600, "Linear layout")
	window.SetTitle("WINC1500 SSL Certificate updater")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)
	window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})
	window.Relayout()
}
开发者ID:adafruit,项目名称:WiFi101-FirmwareUpdater,代码行数:101,代码来源:winc1500-uploader-gui.go


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